private void print_current_chart(PrintJob pj) { Graphics page = pj.getGraphics(); Dimension size = graph_panel.getSize(); Dimension pagesize = pj.getPageDimension(); main_graph.set_symbol(chart.current_tradable().toUpperCase()); if (size.width <= pagesize.width) { // Center the output on the page. page.translate((pagesize.width - size.width) / 2, (pagesize.height - size.height) / 2); } else { // The graph size is wider than a page, so print first // the left side, then the right side. Assumption - it is // not larger than two pages. page.translate(15, (pagesize.height - size.height) / 2); graph_panel.printAll(page); page.dispose(); page = pj.getGraphics(); page.translate(pagesize.width - size.width - 13, (pagesize.height - size.height) / 2); } graph_panel.printAll(page); page.dispose(); main_graph.set_symbol(null); }
/** Prints the drawing. */ public void print() { tool().deactivate(); PrintJob printJob = getToolkit().getPrintJob(this, "Print Drawing", null); if (printJob != null) { Graphics pg = printJob.getGraphics(); if (pg != null) { ((StandardDrawingView) view()).printAll(pg); pg.dispose(); // flush page } printJob.end(); } tool().activate(); }
public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmd.equals("print")) { PrintJob pjob = getToolkit().getPrintJob(this, "RoundedRectTest", null); if (pjob != null) { Graphics pg = pjob.getGraphics(); if (pg != null) { canvas.printAll(pg); pg.dispose(); // flush page } pjob.end(); } } }
/** This internal method begins a new page and prints the header. */ protected void newpage() { page = job.getGraphics(); // Begin the new page linenum = 0; charnum = 0; // Reset line and char number pagenum++; // Increment page number page.setFont(headerfont); // Set the header font. page.drawString(jobname, x0, headery); // Print job name left justified String s = "- " + pagenum + " -"; // Print the page number centered. int w = headermetrics.stringWidth(s); page.drawString(s, x0 + (this.width - w) / 2, headery); w = headermetrics.stringWidth(time); // Print date right justified page.drawString(time, x0 + width - w, headery); // Draw a line beneath the header int y = headery + headermetrics.getDescent() + 1; page.drawLine(x0, y, x0 + width, y); // Set the basic monospaced font for the rest of the page. page.setFont(font); }
public void actionPerformed(ActionEvent e) { PrintJob pjob = getToolkit().getPrintJob(textViewerFrame, "Printing Nslm", null); if (pjob != null) { Graphics pg = pjob.getGraphics(); if (pg != null) { // todo: this should print from // the file not from the screen. // if (editor1!=null) { // editor1.print(pg); //print crashes, must use printAll // } // if (scroller1!=null) { // scroller1.printAll(pg); //is clipping on left // } if (scroller1 != null) { JViewport jvp = scroller1.getViewport(); jvp.printAll(pg); } pg.dispose(); } pjob.end(); } }