Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Timetable - draw items with different width (Read 4553 times)
florea
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 13
Joined: Feb 13th, 2017
Timetable - draw items with different width
Feb 13th, 2017 at 1:01pm
Print Post  
Hi,
I'm evaluating the scheduling product (Java Swing).
I want to build an scheduling calendar for a Day with some resources available for a specific time interval (so for 10-12 AM we might have 2 resource available, between 12-14 only one resource available, between 15-17 3 resource available etc), so the number of resources is not constant for the entire day. I'm thinking of using Timetable without Resource option, but instead of that drawing the items depending of how many resource I have available at a moment of time (for example if the calendar screen width is 600px, between 10-12 AM to draw an item with 300px, for appoiments that are planned between 12-14 to use the entire row 600px, between 15-17 to  draw an item on 200px). I want to keep the "free" space in order to see that I can use that time interval for another appoiment.
Do you know if it is possible to do something like that? (in the attached picture I want the "Free"/green appoiments not to be shown and of course to be resized based in the number of resources)
  

Capture.JPG ( 48 KB | 149 Downloads )
Capture.JPG
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Timetable - draw items with different width
Reply #1 - Feb 13th, 2017 at 2:07pm
Print Post  
Hi,

There is not an elegant way to achieve this. The closes solution I can think of, is creating a custom item viewer and restricting the rectangle where the item is drawn. Here is to implement the custom item viewer:

Code
Select All
public static class MyAppViewer implements ItemViewer
{
	@Override
	public void draw(ItemDrawContext context)
	{
		Rectangle bounds = new Rectangle(context.getBounds());
		if (bounds.width > 300)
			bounds.width = 300;
		context.drawDefault(bounds);
	}
}

@ItemViewerAttribute(viewerType = MyAppViewer.class)
public static class MyApp extends Appointment
{
	public MyApp()
	{
	}
} 


Instruct the calendar that the newly created items are of the new custom type:

Code
Select All
calendar.setInteractiveItemType(MyApp.class); 


However, this solution has various flaws. First, you need to manually calculate the width of each item based on how many resources are available in the item's time slot. Also, the resize bands of the item (when it is selected) cover the actual item size and not what is drawn through the viewer.

Regards,
Meppy
  
Back to top
 
IP Logged
 
florea
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 13
Joined: Feb 13th, 2017
Re: Timetable - draw items with different width
Reply #2 - Feb 13th, 2017 at 2:47pm
Print Post  
Many thanks, from the visual point of view the code does what I need, but i cannot select the same time interval for creating another appoiment for exactly the same the same time interval, somehow the entire "row" is reserved for the old appoiment.
Do you think if there is other option? If I'm using the Resources in a Timetable view, is it possible to activate resources only for some time intervals?
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Timetable - draw items with different width
Reply #3 - Feb 14th, 2017 at 2:21pm
Print Post  
Hi,

We need to make modifications to the control in order to enable this functionality. We will see if we can implement this and I will get back to you.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Timetable - draw items with different width
Reply #4 - Feb 22nd, 2017 at 3:39pm
Print Post  
Hi again,

We have difficulties implementing this specific scenario, because it is hard to decide what should happen when items of different sizes collide. A possible workaround might be to specify the maximum width for all items in the timetable by setting the Calendar.TimetableSettings.MaxItemSize property. For example:

Code
Select All
calendar.getTimetableSettings().setMaxItemSize(100); 


And then eventually use custom drawing to indicate the number of free slots in a specific time interval. Let me know if this solution is acceptable and I will implement the free slot indicator.

Regards,
Meppy
  
Back to top
 
IP Logged
 
florea
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 13
Joined: Feb 13th, 2017
Re: Timetable - draw items with different width
Reply #5 - Feb 28th, 2017 at 8:10am
Print Post  
Hi,
  Thanks for your answer, I already used (for my POC) the workaround with setMaxItemSize. If you are doing anything with free slot indicator please let me know.

Best regards,
Bogdan
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Timetable - draw items with different width
Reply #6 - Feb 28th, 2017 at 1:14pm
Print Post  
Hi,

Check the attached sample (a modified version of the Zones sample). It illustrates how to implement time slots with available resources. When you create an item within a time slot the number to the left indicates the amount of occupied resources and the total number of resources.

Regards,
Meppy
  

MainWindow.txt ( 7 KB | 163 Downloads )
Preview.jpg ( 63 KB | 159 Downloads )
Preview.jpg
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint