List of usage examples for java.awt Rectangle Rectangle
public Rectangle(Point p, Dimension d)
From source file:com.wet.wired.jsr.player.ScreenPlayer.java
private void openStream() { startTime = 0;//from w ww . ja v a 2s. c om frameTime = 0; lastFrameTime = 0; frameNr = 0; running = false; fastForward = false; try { iStream = new RandomAccessFile(videoFile + ".owl.cap", "r"); readFrameIndex(); width = iStream.read(); width = width << 8; width += iStream.read(); height = iStream.read(); height = height << 8; height += iStream.read(); area = new Rectangle(width, height); decompressor = new FrameDecompressor(iStream, width * height); } catch (FileNotFoundException e) { log.error("video file not found", e); exceptionWindow.show(e, "video file not found"); } catch (IOException e) { log.error("cannot read stream from video", e); exceptionWindow.show(e, "cannot read stream from video"); } }
From source file:ded.model.Entity.java
/** Return the primary bounding rectangle for this entity, used for * drawing the selection box and hit testing. Some shapes might * extend a little outside this box visually. */ public Rectangle getRect() { return new Rectangle(this.loc, this.size); }
From source file:userinterface.graph.GUIImageExportDialog.java
/** Creates new form GUIConstantsPicker */ public GUIImageExportDialog(GUIPrism parent, JPanel graph, int defaultImageType) { super(parent, "Provide rendering information", true); this.exportWidth = graph.getWidth(); this.exportHeight = graph.getHeight(); initComponents();//from w w w .j av a2 s . com this.getRootPane().setDefaultButton(okayButton); this.cancelled = false; this.warningLabel.setIcon(GUIPrism.getIconFromImage("smallError.png")); this.warningLabel.setVisible(false); this.widthInputField.getDocument().addDocumentListener(this); this.heightInputField.getDocument().addDocumentListener(this); this.widthInputField.setText("" + exportWidth); this.heightInputField.setText("" + exportHeight); this.imageTypeInputField.setSelectedIndex(defaultImageType); this.alphaInputField.setSelected(false); this.alphaInputField.setEnabled(defaultImageType == PNG); this.alphaInputLabel.setEnabled(defaultImageType == PNG); super.setBounds(new Rectangle(550, 300)); setResizable(true); setLocationRelativeTo(getParent()); // centre this.setVisible(true); }
From source file:Visuals.BarChart.java
public ChartPanel drawBarChart() { DefaultCategoryDataset bardataset = new DefaultCategoryDataset(); bardataset.addValue(new Double(low), "Low (" + low + ")", lowValue); bardataset.addValue(new Double(medium), "Medium (" + medium + ")", mediumValue); bardataset.addValue(new Double(high), "High (" + high + ")", highValue); bardataset.addValue(new Double(critical), "Critical (" + critical + ")", criticalValue); JFreeChart barchart = ChartFactory.createBarChart(title, // Title riskCategory, riskCountTitle, bardataset // Dataset );/* w w w . j a va2 s.c om*/ final CategoryPlot plot = barchart.getCategoryPlot(); CategoryItemRenderer renderer = new CustomRenderer(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); renderer.setBaseItemLabelGenerator( new StandardCategoryItemLabelGenerator(riskCountTitle, NumberFormat.getInstance())); DecimalFormat df = new DecimalFormat("##"); renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", df)); Font m1Font; m1Font = new Font("Cambria", Font.BOLD, 16); renderer.setItemLabelFont(m1Font); renderer.setItemLabelPaint(null); //barchart.removeLegend(); plot.setRenderer(renderer); //renderer.setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE5, TextAnchor.CENTER)); //renderer.setItemLabelsVisible(true); barchart.getCategoryPlot().setRenderer(renderer); LegendItemCollection chartLegend = new LegendItemCollection(); Shape shape = new Rectangle(10, 10); chartLegend.add(new LegendItem("Low (" + low + ")", null, null, null, shape, new Color(230, 219, 27))); chartLegend .add(new LegendItem("Medium (" + medium + ")", null, null, null, shape, new Color(85, 144, 176))); chartLegend.add(new LegendItem("High (" + high + ")", null, null, null, shape, new Color(230, 90, 27))); chartLegend.add( new LegendItem("Critical (" + critical + ")", null, null, null, shape, new Color(230, 27, 27))); plot.setFixedLegendItems(chartLegend); plot.setBackgroundPaint(new Color(210, 234, 243)); ChartPanel chartPanel = new ChartPanel(barchart); return chartPanel; }
From source file:com.alvermont.terraj.util.io.ImagePrinter.java
/** * Scale the image to fit in the X direction. Note the image is * unchanged, the scaling of the Graphics2D is what gets changed *//*from ww w.j a v a 2 s . c o m*/ public void scaleToFitX() { final Rectangle componentBounds = new Rectangle(getImage().getWidth(), getImage().getHeight()); final double newScaleX = this.getFormat().getImageableWidth() / componentBounds.width; final double newScaleY = newScaleX; if (newScaleX < 1) { setScale(newScaleX, newScaleY); } }
From source file:com.redhat.thermostat.byteman.plot.impl.TestPlotRenderer.java
private static void chartToSvg(JFreeChart chart, int width, int height, String filename) throws Exception { Writer writer = null;//from w w w. j a v a2 s. com try { DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation(); Document document = domImpl.createDocument(null, "svg", null); SVGGraphics2D svgGenerator = new SVGGraphics2D(document); svgGenerator.setSVGCanvasSize(new Dimension(width, height)); chart.draw(svgGenerator, new Rectangle(width, height)); OutputStream os = new FileOutputStream(filename + ".svg"); writer = new BufferedWriter(new OutputStreamWriter(os, Charset.forName("UTF-8"))); svgGenerator.stream(writer); } finally { closeQuietly(writer); } }
From source file:com.alvermont.terraj.util.io.ImagePrinter.java
/** * Scale the image to fit in the Y direction. Note the image is * unchanged, the scaling of the Graphics2D is what gets changed *///from www .jav a 2s. c o m public void scaleToFitY() { final Rectangle componentBounds = new Rectangle(getImage().getWidth(), getImage().getHeight()); final double newScaleY = getFormat().getImageableHeight() / componentBounds.height; final double newScaleX = newScaleY; if (newScaleY < 1) { setScale(newScaleX, newScaleY); } }
From source file:mrmc.chart.StudyDesignPlot.java
/** * Constructs the chart/*from w ww . j a v a 2 s . co m*/ * * @param dataset Representation of x-y data * @param title Title of chart * @param xaxis Label for x-axis * @param yaxis Label for y-axis * @return The chart */ private JFreeChart createChart(final DefaultXYDataset dataset, String title, String xaxis, String yaxis) { final JFreeChart chart = ChartFactory.createScatterPlot(title, xaxis, yaxis, dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = (XYPlot) chart.getPlot(); NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis(); ; rangeAxis.setLowerBound(-.5); rangeAxis.setTickUnit(new NumberTickUnit(1)); XYItemRenderer renderer = xyplot.getRenderer(); Rectangle square = new Rectangle(5, 5); renderer.setSeriesShape(0, square); renderer.setSeriesShape(1, square); renderer.setSeriesPaint(0, Color.white); renderer.setSeriesPaint(1, Color.black); return chart; }
From source file:com.seleniumtests.ut.driver.TestCustomEventFiringWebDriver.java
@BeforeMethod(groups = { "ut" }) private void init() throws Exception { PowerMockito.spy(CustomEventFiringWebDriver.class); // add DriverExceptionListener to reproduce driver behavior eventDriver = spy(//from w ww .j av a2s . c o m new CustomEventFiringWebDriver(driver, null, browserInfo, true, DriverMode.LOCAL, null, null) .register(new DriverExceptionListener())); when(driver.manage()).thenReturn(options); when(driver.getSessionId()).thenReturn(new SessionId("1234")); when(driver.getPageSource()).thenReturn("<html></html>"); when(options.window()).thenReturn(window); when(window.getSize()).thenReturn(new Dimension(100, 100)); PowerMockito.mockStatic(OSUtilityFactory.class); when(OSUtilityFactory.getInstance()).thenReturn(osUtility); PowerMockito.whenNew(Robot.class).withNoArguments().thenReturn(robot); PowerMockito.whenNew(VideoRecorder.class).withAnyArguments().thenReturn(videoRecorder); PowerMockito.whenNew(Keyboard.class).withNoArguments().thenReturn(keyboard); PowerMockito.doReturn(new Rectangle(1900, 1000)).when(CustomEventFiringWebDriver.class, "getScreensRectangle"); }
From source file:com.alvermont.terraj.util.io.ImagePrinter.java
/** * Scale the image to fit the printable area in both the X and Y * directions.// ww w . j ava 2 s. co m * * @param useSymmetricScaling If <pre>true</pre> then scale the * image in a symmetric manner */ public void scaleToFit(boolean useSymmetricScaling) { final Rectangle componentBounds = new Rectangle(this.getImage().getWidth(), this.getImage().getHeight()); double newScaleX = this.getFormat().getImageableWidth() / componentBounds.width; double newScaleY = this.getFormat().getImageableHeight() / componentBounds.height; log.debug("Scale for printing: " + newScaleX + " " + newScaleY); if ((newScaleX < 1) || (newScaleY < 1)) { if (useSymmetricScaling) { if (newScaleX < newScaleY) { newScaleY = newScaleX; } else { newScaleX = newScaleY; } } setScale(newScaleX, newScaleY); } }