The code below gives no indication of what could cause
intermittent problems.
If its a problem in both copying to the clipboard and
printing its seems likely to be a general bug in your code.
I guess you are drawing to an image.
Perhaps you have an inappropriate use of multiple threads
and you are using the image before rendering is complete.
-phil.
Olsen Chris wrote:
Hello All --
I am experiencing a vexing problem trying to send contents of a
Component to the clipboard, printer, or save-to-jpeg. All of my
procedures use the drawPage method below to send the graphs to the
targets. I have been able to successfully get contents to each of these
targets, but a problem intermittently occurs; that is it occurs with
some graphs and not with others. Sometimes the text (using drawString)
gets lost on the way to the clipboard, printer, and save-to-jpeg,
leaving a textless graph.
In some cases simply rearranging the calls (e.g. drawStrings performed
after other graphics) is successful, and other times no. I have
included what I hope is representative code. The drawStringInfo
basically draws text, and the drawHorizScale basically draws lines.
I feel there must be some general principle in the painting (or
wherever) that I'm not understanding. All my graphs get to the screen
w/o problem one! Does this problem ring a bell with anyone? (And, more
importantly, does a solution come with the ringing??)
Thank you in advance for any help, and thanks to all those I have
learned so much from as I lurk...
---------------------------------------------------------
public void drawPage(Graphics2D g2)
{
g2.setFont(new Font("Monospaced", Font.BOLD, 12));
drawHorizScale(g2);
drawStringInfo(g2);
}
private void drawStringInfo(Graphics2D g2)
{
g2.drawString("Bldg = " + bldgName, 10, 20);
g2.drawString("Tchr = " + tchrName, 10, 35);
g2.drawString("**** Item Statistics ****", 50, 50);
g2.drawString("*** p-Values vs. Building Residuals ***", 380,
50);
g2.drawString("Itm BRes pVal", 15, 100);
g2.drawString("Itm BRes pVal", 160, 100);
g2.drawString("Building Residual", 500, 580);
return;
}
public void drawHorizScale(Graphics2D g2)
{
g2.drawLine(smallExtent, horizLineLevel, largeExtent,
horizLineLevel);
// Draw small x ticks
for (double hMark = startPrintScale; hMark < stopPrintScale; hMark
= hMark + smallTickInterval)
{
if ((loEndOfScale <= hMark) && (hMark <= hiEndOfScale))
{
int screenXCoord = getScreenX(hMark);
g2.drawLine(screenXCoord, horizLineLevel, screenXCoord,
horizLineLevel + 5);
}
}
}
---------------------------------------------------------------------
-- Chris
Chris Olsen
Assessment Facilitator
Cedar Rapids Community Schools
1243 20th St. SW
Cedar Rapids, IA 52404
===========================================================================
To unsubscribe, send email to lists...@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
lists...@java.sun.com and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to lists...@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
lists...@java.sun.com and include in the body of the message "help".