Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) resourceview calendar time range and cell lines (Read 849 times)
Raees
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 2
Joined: Nov 14th, 2024
resourceview calendar time range and cell lines
Nov 15th, 2024 at 2:17pm
Print Post  
Hi, i got the JPlanner trial for the scheduling and i've being trying to work with it to determine if its going to respond to what i want to do with my application. i got a few questions/issues while i was working around with the sample code.

1) How can i specify the time range(startDate, EndDate) i want to display within the calendar and have it fit the screen. I've already tried the following with no succes:
Code (Java)
Select All
calendar.setDate(DateTime.today());
		calendar.setEndDate(DateTime.now().addHours(10));
		calendar.setViewport(DateTime.today(), DateTime.today().addHours(10),true); 



2) How can I rid of the vertical lines in the resourceview. i've tried the following but i can only seem to either remove all the gridlines or have them dotted;
Code (Java)
Select All
calendar.getResourceViewSettings().setGridStyle(LineStyle.Invisible); 



3) Is there a way i can use a custom color for the items in the calendar, not just the bar on top but the whole item.

I would be grateful for any help, any direction or insight on things am missing Smiley

Here is an illustration of the issue within the app itself and also a concept of what i am trying to obtain:

Regards.


  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Online


tech.support

Posts: 3343
Joined: Oct 19th, 2005
Re: resourceview calendar time range and cell lines
Reply #1 - Nov 15th, 2024 at 3:20pm
Print Post  
Hi,

1. Resource view calculates the size of its cells dynamically to fit the text of units specified for timelines. setViewport lets you change cell size, but it's a one-time operation that takes into account current calendar size. So if you want to always fit 12 hours, you could do that from componentResized event:

Code
Select All
calendar.addComponentListener(new ComponentAdapter()
{
    @Override
    public void componentResized(ComponentEvent e)
    {
        fitResView();
    }
});

private void fitResView()
{
    ResourceViewSettings res = calendar.getResourceViewSettings();
    res.setTimelines(2);
    res.getMiddleTimelineSettings().setUnit(TimeUnit.Day);
    res.getBottomTimelineSettings().setUnit(TimeUnit.Hour);
    res.getBottomTimelineSettings().setFormat("HH");
    res.getBottomTimelineSettings().setUnitCount(1);
    calendar.setViewport(
        calendar.getFirstDate(), calendar.getFirstDate().addHours(12), false);
} 


  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Online


tech.support

Posts: 3343
Joined: Oct 19th, 2005
Re: resourceview calendar time range and cell lines
Reply #2 - Nov 15th, 2024 at 3:31pm
Print Post  
2. I'm not seeing any lines after calling setGridStyle(LineStyle.Invisible), but maybe also try setting InnerGridStyle for your configuration:

Code
Select All
calendar.getResourceViewSettings().setGridStyle(LineStyle.Invisible);
calendar.getResourceViewSettings().setInnerGridStyle(LineStyle.Invisible); 



If it still shows the lines, please attach a test project reproducing that for our developer to investigate
  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Online


tech.support

Posts: 3343
Joined: Oct 19th, 2005
Re: resourceview calendar time range and cell lines
Reply #3 - Nov 15th, 2024 at 3:41pm
Print Post  
3. You can customize global item appearance through ItemSettings object:

Code
Select All
Style itemStyle = calendar.getItemSettings().getStyle();
itemStyle.setHeaderBrush(new SolidBrush(Color.green)); 



or alternatively set the Style property of individual items.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Raees
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 2
Joined: Nov 14th, 2024
Re: resourceview calendar time range and cell lines
Reply #4 - Nov 15th, 2024 at 4:35pm
Print Post  
Hi,
Thank you for the return

1) i did try the suggested code and it works perfectly well

2) I've already tried this but it gets all the lines invisible. i wish to keep the lines that seperates the rows like in the concept and remove the vertical lines, not to remove them all completly. image illustrates it #2

Edit: I just figured where the vertical lines originate from. Its from the setUnitCount from my bottomtimelinesettings. i have a vertical line at every 15 minute mark. is there a work around if i wish to keep the unitcount?
Code (Java)
Select All
res.getBottomTimelineSettings().setUnit(TimeUnit.Minute);
		res.getBottomTimelineSettings().setFormat("mm");
		res.getBottomTimelineSettings().setUnitCount(15);
		res.getBottomTimelineSettings().setExtendedCurrentTimeMarker(true);
		res.getBottomTimelineSettings().setSize(20);
		res.getBottomTimelineSettings().setTickSize(3);
		res.getBottomTimelineSettings().setShowCurrentTime(true); 



3) This works aswell!!

4) One more thing i would like to know is, is it possible to add periodes/rectangle blocks where the Pier (row) isnt available for booking. this is to just illustrate that the pier is unavailable during a specified date (startDate, endDate) like in the image below #4.


Regards

  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Online


tech.support

Posts: 3343
Joined: Oct 19th, 2005
Re: resourceview calendar time range and cell lines
Reply #5 - Nov 18th, 2024 at 8:17am
Print Post  
Hi,

2. At this time you cannot hide only the vertical grid lines. Try custom drawing the horizontal ones instead:

Code
Select All
res.setGridStyle(LineStyle.Invisible);
res.setInnerGridStyle(LineStyle.Invisible);
calendar.setCustomDraw(
    EnumSet.of(CustomDrawElements.ResourceViewCell));

calendar.addCalendarListener(new CalendarAdapter()
{
    @Override
    public void draw(CalendarDrawEvent e)
    {
        if (e.getElement() == CustomDrawElements.ResourceViewCell)
        {
            Rectangle2D r = e.getBounds();
            Utilities.drawLine(
                e.getGraphics(), new Pen(Color.red),
                r.getMinX(), r.getMaxY() - 1, r.getMaxX(), r.getMaxY() - 1);
        }
    }
    ...
 

  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Online


tech.support

Posts: 3343
Joined: Oct 19th, 2005
Re: resourceview calendar time range and cell lines
Reply #6 - Nov 18th, 2024 at 8:33am
Print Post  
4) You could add locked appointments to identify unavailable times, and style them accordingly via item's Style property. If you prefer to keep these out of the schedule model, try custom drawing as in this thread:

https://mindfusion.eu/Forum/YaBB.pl?num=1659043839/3#3

where unavailable times are stored in the 'occupied' list.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Raeees
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 10
Joined: Dec 11th, 2024
Re: resourceview calendar time range and cell lines
Reply #7 - Dec 11th, 2024 at 3:44pm
Print Post  
Hi again,
its me with a different account, the password reset isnt working for some reason.

I would like to know if its possible to save the calendar to a pdf file. As of now, i know you can produce pdf files with other diagrams available on your site using PDFExporter but not with scheduling calendar. IF its possible, can you show me how or if it isnt, care you to show me other methods i can try?.
Thanks once again
  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Online


tech.support

Posts: 3343
Joined: Oct 19th, 2005
Re: resourceview calendar time range and cell lines
Reply #8 - Dec 11th, 2024 at 5:23pm
Print Post  
Hi,

Diagram's PDF export is implemented by calling diagram.draw method on a PdfGraphics2D instance. So if you use our Java Swing's pack jar file to include PdfGraphics2D and call calendar's print method, you can get a PDF representation of the calendar like this:

Code
Select All
try
{
	PdfGraphics2D graphics = new PdfGraphics2D(
		calendar.getBounds(), GraphicsUnit.Point);
	graphics.setMarginBottom(0);
	graphics.setMarginTop(0);
	graphics.setMarginLeft(0);
	graphics.setMarginRight(0);
	graphics.rearrange(
		GraphicsUnit.Pixel, calendar.getBounds());
	Globals.defaultCharset = "UTF8";

	graphics.createPage();

	graphics.setClip(calendar.getBounds());

	Paper paper = new Paper();
	paper.setSize(
		calendar.getBounds().getWidth(),
		calendar.getBounds().getHeight());
	paper.setImageableArea(
		0, 0, calendar.getBounds().getWidth(), calendar.getBounds().getHeight());
	PageFormat format = new PageFormat();
	format.setPaper(paper);
	calendar.print(graphics, format, 0);
	graphics.save("D:\\test.pdf");
}
catch (IOException e)
{
	e.printStackTrace();
} 



Doing that via print method because I can't see any other public methods for drawing to take a Graphics2D argument. Alternatively you could derive from Calendar to have access to the protected paintComponent method, and draw by calling it instead.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Raeees
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 10
Joined: Dec 11th, 2024
Re: resourceview calendar time range and cell lines
Reply #9 - Dec 11th, 2024 at 6:08pm
Print Post  
Thank you very much, this works and i'll continue working around this.

Another question though,

Code (Java)
Select All
calendar.getItemSettings().setSize(18); 


this line is supposed to reduce the size (height) of the items in the calendar, using resourceview. but it doesnt seem to work, unless there is some setting restricting this. i would like to reduce the height of my items shown in the image

2)- Pressing on the Resource "Pier" keeps throwing the following exception

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class com.mindfusion.scheduling.model.ResourceList (java.util.ArrayList is in module java.base of loader 'bootstrap'; com.mindfusion.scheduling.model.ResourceList is in unnamed module of loader 'app')
     at com.mindfusion.scheduling.bq.a(Unknown Source)
     at com.mindfusion.scheduling.bq.update(Unknown Source)
     at com.mindfusion.scheduling.Calendar.a(Unknown Source)
     at com.mindfusion.scheduling.Calendar.mousePressed(Unknown Source)
     at java.desktop/java.awt.Component.processMouseEvent(Component.java:6618)
     at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3398)
     at java.desktop/java.awt.Component.processEvent(Component.java:6386)
     at java.desktop/java.awt.Container.processEvent(Container.java:2266)
     at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4996)
     at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
     at java.desktop/java.awt.Component.dispatchEvent(Component.java:4828)
     at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:49
48)
     at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:457
2)
     at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516)
     at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
     at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2780)
     at java.desktop/java.awt.Component.dispatchEvent(Component.java:4828)
     at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:775)
     at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
     at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
     at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)

     at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPr
ivilege(ProtectionDomain.java:87)
     at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPr
ivilege(ProtectionDomain.java:98)
     at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:747)
     at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
     at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)

     at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPr
ivilege(ProtectionDomain.java:87)
     at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:744)
     at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchTh
read.java:203)
     at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThrea
d.java:124)
     at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchTh
read.java:113)
     at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:10
9)
     at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:10
1)
     at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Thanks once again!
  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Online


tech.support

Posts: 3343
Joined: Oct 19th, 2005
Re: resourceview calendar time range and cell lines
Reply #10 - Dec 12th, 2024 at 11:18am
Print Post  
Hi,

1) I think that's used only for free-floating items as in list view. For resource view try setting the lane size instead:

Code
Select All
calendar.getResourceViewSettings().setLaneSize(50); 


  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Online


tech.support

Posts: 3343
Joined: Oct 19th, 2005
Re: resourceview calendar time range and cell lines
Reply #11 - Dec 12th, 2024 at 11:42am
Print Post  
2) seems to come from the resource reorder tool for custom resource grouping type.  Until our developer fixes that, you could disable the ResourceViewSettings.AllowReorderResources property.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Raeees
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 10
Joined: Dec 11th, 2024
Re: resourceview calendar time range and cell lines
Reply #12 - Dec 12th, 2024 at 1:15pm
Print Post  
Hello,

hmmm, i think its better to have item size independant on lane size, so that i can display custom lane sizes without item sizes changing accordling.
on another note, yes i disabled ''allowreorderResources'', that seems to have fixed it

Once again, thank you for the quick assistance
  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Online


tech.support

Posts: 3343
Joined: Oct 19th, 2005
Re: resourceview calendar time range and cell lines
Reply #13 - Dec 13th, 2024 at 11:54am
Print Post  
Hi,

New jar here should fix the exception -

https://mindfusion.eu/_beta/jplanner223.zip

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Raeees
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 10
Joined: Dec 11th, 2024
Re: resourceview calendar time range and cell lines
Reply #14 - Jan 15th, 2025 at 6:07pm
Print Post  
Hi,

So i did try what you suggested at Reply #6 when locking down lanes during a determined period and it works. thank you for that

Now, i wish to know if its possible to display text in a Lane, when i try this with
Code (Java)
Select All
e.getElement() == CustomDrawElements.ResourceViewCellComplete 



the text is being displayed in each cell, as shown in the image, but i would like to have it writted once and centered in the lane.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint