Page Index Toggle Pages: 1 [2]  Send TopicPrint
Hot Topic (More than 10 Replies) resourceview calendar time range and cell lines (Read 837 times)
Slavcho
God Member
*****
Online


tech.support

Posts: 3340
Joined: Oct 19th, 2005
Re: resourceview calendar time range and cell lines
Reply #15 - Jan 16th, 2025 at 1:21pm
Print Post  
Hi,

Each time interval maps to a separate cell (whose borders you wanted to hide earlier) and the 'Complete' suffix only means all lanes in that time interval. We'll have in mind adding complete-row custom drawing for next release. At this time you could draw text only in the middle cell of the row, e.g.

Code
Select All
if (e.getElement() == CustomDrawElements.ResourceViewCellComplete)
{
	if (bounds.getMinX() <= calendar.getWidth() / 2 &&
		calendar.getWidth() / 2 < bounds.getMaxX())
	{
		e.getGraphics().drawString(
			"test", (int)bounds.getMinX(), (int)bounds.getCenterY());
	}
} 



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 #16 - Jan 24th, 2025 at 8:01pm
Print Post  
using reply#8 suggestion on saving the calendar to pdf. i took that example further to only select resource rows am interested in. however when saving those graphics, i come accross an error that doesnt seem to make sense. the names of certain items in the row arent displayed. can you assist me on this? Here is the code i use to chose rows and save them

Code (Java)
Select All
try {

			Paper paper = new Paper();
			paper.setSize(8.5*72, 11*72);
			paper.setImageableArea(
					0,
					0,
					8.5*72,
					11*72);
			PageFormat format = new PageFormat();
			format.setOrientation(PageFormat.LANDSCAPE);
			format.setPaper(paper);

			double x1= calendar.getElementBounds(CalendarElement.ResourceViewHeader,2).getBounds().getMinX();
			double y1= calendar.getElementBounds(CalendarElement.ResourceViewHeader,2).getBounds().getMinY();
			double y2= calendar.getElementBounds(CalendarElement.ResourceViewCell,2).getBounds().getHeight();
			double x2= calendar.getBounds().getBounds().getWidth();

			Rectangle2D r2 = new Rectangle2D.Double(x1,y1,x2,y2);

			RenderingHints rh = new RenderingHints(
					RenderingHints.KEY_ANTIALIASING,
					RenderingHints.VALUE_ANTIALIAS_ON);
			PdfGraphics2D graphics = new PdfGraphics2D(
					r2, GraphicsUnit.Point);

			graphics.setMarginBottom(5);
			graphics.setMarginTop(5);
			graphics.setMarginLeft(5);
			graphics.setMarginRight(5);
			graphics.setRenderingHints(rh);
			graphics.rearrange(
					GraphicsUnit.Point, r2);

			Globals.defaultCharset = "UTF8";
			graphics.createPage();
			graphics.setClip(r2.getBounds());


			calendar.print(graphics,format,0);
			graphics.save("SavedPDF.pdf");
			graphics.dispose();

		}catch (IOException e) {
			e.printStackTrace();
		} 

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


tech.support

Posts: 3340
Joined: Oct 19th, 2005
Re: resourceview calendar time range and cell lines
Reply #17 - Jan 27th, 2025 at 1:31pm
Print Post  
That looks like all items with X coordinate greater than a certain position. It could be the control calculates text layout with some delay or applies internal text clipping. Are these items off-screen at the time of export? Alternatively try setting a larger clip width or removing the clip path (in case our PdfGraphics implementation applies it to text but not rectangles).
  
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 #18 - Jan 27th, 2025 at 3:13pm
Print Post  
Yes, when i use
Code (Java)
Select All
calendar.printPreview(format); 


the items in the end are offscreen, which might be the cause of this. I still dont understand, if they are offscreen, how am i able to still print the items but not their headerText.

EDIT: so calendar prints its content on PdfGraphics but leaves out the text?
Code (Java)
Select All
calendar.print(graphics,format,0); 

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


tech.support

Posts: 3340
Joined: Oct 19th, 2005
Re: resourceview calendar time range and cell lines
Reply #19 - Jan 28th, 2025 at 12:26pm
Print Post  
It looks like you are passing smaller rectangle to print (via Paper instance's size) than to PdfGraphics pages (via rearrange). So in that case the pagination code might be skipping drawString calls outside of Paper size completely, while relying on clipping for the rectangles, but PdfGraphics not performing clipping as expected due to its larger size.

Our test code above is passing same sizes to both Paper and PdfGraphics, from calendar.getBounds result. Maybe in your case try passing the r2 size to both.

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 #20 - Jan 29th, 2025 at 3:24pm
Print Post  
After further investigation, it does work. what i do suspect is the format change from landscape to portrait size isnt applied to the item text.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 [2] 
Send TopicPrint