[JAVA2D] Problem in printing on specfic printer on network

2009-02-26 Thread java2d
Hi Everyone

I am working one swing application which need to print on some specific
printer on network. Method which I am using is given below. In this
method i am passing the printer name as parameter and string which is
to be printed is present in the class member [b]printString[/b].

public boolean print(String printerName) {
boolean result = false;
try {
ByteArrayInputStream bais = new 
ByteArrayInputStream(printContent.getBytes());
PrintService[] services = 
PrinterJob.lookupPrintServices();
String [] printerNameList = new String[services.length];
for(int count = 0; count < services.length; count++) {
printerNameList[count] = 
services[count].getName();
if 
(printerNameList[count].equalsIgnoreCase(printerName)) {
DocPrintJob job = 
services[count].createPrintJob();
DocFlavor flavor = 
DocFlavor.BYTE_ARRAY.AUTOSENSE;
Doc doc = new 
SimpleDoc(printContent.getBytes(), flavor, null);
PrintRequestAttributeSet attributes = 
new HashPrintRequestAttributeSet();
attributes.add(new Copies(1));

PrintJobWatcher pjDone = new 
PrintJobWatcher(job);

job.print(doc, attributes);

pjDone.waitForDone();

bais.close();

result = true;
break;
}
}
}
catch(PrintException ex) {
String message = "Error on while printing the content 
on the printer : "  + ex.getMessage();
System.out.println(message);
ApplicationLogger.getInstance().error(message);
}
catch(Exception ex) {
String message = "Error on while printing the content : 
"  + ex.getMessage();
System.out.println(message);
ApplicationLogger.getInstance().error(message);
}
return result;
}

Here is the code for PrintJobWatcher 

class PrintJobWatcher {
// true iff it is safe to close the print job's input stream
boolean done = false;

PrintJobWatcher(DocPrintJob job) {
// Add a listener to the print job
job.addPrintJobListener(new PrintJobAdapter() {
public void printJobCanceled(PrintJobEvent event) {
allDone();
}
public void printJobCompleted(PrintJobEvent event) {
allDone();
}
public void printJobFailed(PrintJobEvent event) {
allDone();
}
public void printJobNoMoreEvents(PrintJobEvent event) {
allDone();
}
void allDone() {
synchronized (PrintJobWatcher.this) {
done = true;
PrintJobWatcher.this.notify();
}
}
});
}
public synchronized void waitForDone() {
try {
while (!done) {
wait();
}
}
catch (InterruptedException e) {
}
}
}

But my string is not being printed. Please tell where I am doing mistake.

Thanks in advance
Shashwat
[Message sent by forum member 'shashwat_anand' (shashwat_anand)]

http://forums.java.net/jive/thread.jspa?messageID=333974

===
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".


Re: [JAVA2D] Problem in printing on specfic printer on network

2009-02-26 Thread Jennifer Godinez

Hi Shashwat,

I cannot find string "printString" anywhere in the code so I don't know which string you are 
referring to that is not printed.  Looking at your code though, I noticed that in order to monitor 
your print job, PrintJobWatcher should implement PrintJobListener and attached to "job" which was 
created using createPrintJob. See the documnetation on PrintJobListener for more information.


Jennifer

jav...@javadesktop.org wrote:

Hi Everyone

I am working one swing application which need to print on some specific
printer on network. Method which I am using is given below. In this
method i am passing the printer name as parameter and string which is
to be printed is present in the class member [b]printString[/b].

public boolean print(String printerName) {
boolean result = false;
try {
ByteArrayInputStream bais = new 
ByteArrayInputStream(printContent.getBytes());
PrintService[] services = 
PrinterJob.lookupPrintServices();
String [] printerNameList = new String[services.length];
for(int count = 0; count < services.length; count++) {
printerNameList[count] = 
services[count].getName();
if 
(printerNameList[count].equalsIgnoreCase(printerName)) {
DocPrintJob job = 
services[count].createPrintJob();
DocFlavor flavor = 
DocFlavor.BYTE_ARRAY.AUTOSENSE;
Doc doc = new 
SimpleDoc(printContent.getBytes(), flavor, null);
PrintRequestAttributeSet attributes = 
new HashPrintRequestAttributeSet();
attributes.add(new Copies(1));

PrintJobWatcher pjDone = new 
PrintJobWatcher(job);

job.print(doc, attributes);

pjDone.waitForDone();

bais.close();

result = true;
break;
}
}
}
catch(PrintException ex) {
String message = "Error on while printing the content on the 
printer : "  + ex.getMessage();
System.out.println(message);
ApplicationLogger.getInstance().error(message);
}
catch(Exception ex) {
String message = "Error on while printing the content : 
"  + ex.getMessage();
System.out.println(message);
ApplicationLogger.getInstance().error(message);
}
return result;
}

Here is the code for PrintJobWatcher 


class PrintJobWatcher {
// true iff it is safe to close the print job's input stream
boolean done = false;

PrintJobWatcher(DocPrintJob job) {

// Add a listener to the print job
job.addPrintJobListener(new PrintJobAdapter() {
public void printJobCanceled(PrintJobEvent event) {
allDone();
}
public void printJobCompleted(PrintJobEvent event) {
allDone();
}
public void printJobFailed(PrintJobEvent event) {
allDone();
}
public void printJobNoMoreEvents(PrintJobEvent event) {
allDone();
}
void allDone() {
synchronized (PrintJobWatcher.this) {
done = true;
PrintJobWatcher.this.notify();
}
}
});
}
public synchronized void waitForDone() {
try {
while (!done) {
wait();
}
}
catch (InterruptedException e) {
}
}
}

But my string is not being printed. Please tell where I am doing mistake.

Thanks in advance
Shashwat
[Message sent by forum member 'shashwat_anand' (shashwat_anand)]

http://forums.java.net/jive/thread.jspa?messageID=333974

===
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, 

[JAVA2D] bad return value from GraphicsDevice.getAvailableAcceleratedMemory()?

2009-02-26 Thread java2d
Windows XP, SP3
java -version 1.6.0_11-b03
nvidia 8400GS with 512mb of Vram

In earlier builds calling GraphicsDevice.getAvailableAcceleratedMemory() seemed 
to return a proper vram value.  I've noticed that in more recent versions it is 
returning inaccurate values.  On this particular machine calling it returns a 
value of 610 MB (639631360 bytes).

On a newer vista 64 machine with an 512MB nvidia graphics card the call returns 
a large negative value. (about -1500MB).

On a third winXP machine with a 128MB nvidia 5900 card it returns 176MB.

The values are similar if I call the method right after creating the 
GraphicsDevice, after creating a buffer strategy, or after creating a seperate 
volatile image.

Is this a known bug, or did something change?
[Message sent by forum member 'donmc' (donmc)]

http://forums.java.net/jive/thread.jspa?messageID=334127

===
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".


Re: [JAVA2D] Problem in printing on specfic printer on network

2009-02-26 Thread java2d
Hi Jennifer

Sorry I wrongly wrote it is not printString it is printContent, so now I edited 
it. I am trying your suggestion but I think so the problem that my doc favor is 
not recognized by printer. When I debugged my program execution goes to the 
printDataTransferCompleted() and then printJobNoMoreEvents() methods of 
PrintJobListener interface but string is not getting printed. I have HP 
laserjet as my network printer.

Thanks for your help
Shashwat
[Message sent by forum member 'shashwat_anand' (shashwat_anand)]

http://forums.java.net/jive/thread.jspa?messageID=334130

===
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".


Re: [JAVA2D] bad return value from GraphicsDevice.getAvailableAcceleratedMemory()?

2009-02-26 Thread Dmitri Trembovetski

  Unfortunately, this is just the way Direct3D 9 reports the amount of
  available video memory. It makes even less sense on windows Vista because
  video memory is virtualized there and is basically limited by your
  swap size.

  Earlier releases used DirectX 7 where the amount of vram reported
  was closer to the real thing.

  Thanks,
Dmitri


jav...@javadesktop.org wrote:

Windows XP, SP3
java -version 1.6.0_11-b03
nvidia 8400GS with 512mb of Vram

In earlier builds calling GraphicsDevice.getAvailableAcceleratedMemory() seemed 
to return a proper vram value.  I've noticed that in more recent versions it is 
returning inaccurate values.  On this particular machine calling it returns a 
value of 610 MB (639631360 bytes).

On a newer vista 64 machine with an 512MB nvidia graphics card the call returns 
a large negative value. (about -1500MB).

On a third winXP machine with a 128MB nvidia 5900 card it returns 176MB.

The values are similar if I call the method right after creating the 
GraphicsDevice, after creating a buffer strategy, or after creating a seperate 
volatile image.

Is this a known bug, or did something change?
[Message sent by forum member 'donmc' (donmc)]

http://forums.java.net/jive/thread.jspa?messageID=334127

===
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".


[JAVA2D] How to fill the area between two parallel arcs

2009-02-26 Thread java2d
I am new to Java AWT.
Can any one help in how to fill the area between two parallel arcs ?

Thanks
[Message sent by forum member 'raghavareddy' (raghavareddy)]

http://forums.java.net/jive/thread.jspa?messageID=334137

===
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".