List of usage examples for java.awt Dimension getWidth
public double getWidth()
From source file:com.loyalty.controllers.DashboardController.java
private void animate() { Toolkit tk = Toolkit.getDefaultToolkit(); Dimension screenDimension = tk.getScreenSize(); TranslateTransition transition = new TranslateTransition(new Duration(30000), lbl_promotion); transition.setInterpolator(Interpolator.LINEAR); transition.setCycleCount(Timeline.INDEFINITE); transition.setFromX(screenDimension.getWidth()); transition.setToX(-screenDimension.getWidth()); transition.play();//from w ww.j av a 2 s . c om }
From source file:InterfaceGrafica.java
/** * ler a topologia da memria secundria e desenha o grfico *///from w ww. j a v a 2s . com private void adicionaGrafico(String[][] nodesConnections) { DirectedSparseGraph g = new DirectedSparseGraph(); int numeroEdge = 0; for (String[] connection : nodesConnections) { if (!g.containsVertex(connection[0])) { g.addVertex(connection[0]); } if (!g.containsVertex(connection[1])) { g.addVertex(connection[1]); } g.addEdge(Integer.toString(numeroEdge), connection[0], connection[1]); numeroEdge++; } Transformer<String, String> transformer = (String arg) -> arg; Dimension dimension = graficoPanel.getSize(); VisualizationViewer visualizationViewer = new VisualizationViewer(new CircleLayout(g), new Dimension((int) dimension.getWidth(), (int) (dimension.getHeight() * HEIGHT_REDIMENSION))); visualizationViewer.setBackground(Color.WHITE); visualizationViewer.getRenderContext().setVertexLabelTransformer(transformer); graficoPanel.setLayout(new BorderLayout()); graficoPanel.add(visualizationViewer); graficoPanel.revalidate(); }
From source file:nl.b3p.viewer.print.PrintInfo.java
public void cacheLegendImagesAndReadDimensions() { for (Legend l : legendUrls) { for (LegendPart lp : l.getLegendParts()) { File legendFile = null; InputStream in = null; ByteArrayOutputStream legendMemoryCache = new ByteArrayOutputStream(); FileOutputStream fos = null; try { log.debug("Loading legend from URL: " + lp.getUrl()); URL u = new URL(lp.getUrl()); in = u.openStream();/* w w w. j a v a 2 s . c o m*/ IOUtils.copy(in, legendMemoryCache); legendFile = File.createTempFile("legend_img_", null); tempFiles.add(legendFile); legendFile.deleteOnExit(); fos = new FileOutputStream(legendFile); IOUtils.copy(new ByteArrayInputStream(legendMemoryCache.toByteArray()), fos); fos.flush(); lp.setUrl(legendFile.toURI().toString()); log.debug("Legend part url changed to point to temporary file: " + lp.getUrl()); Dimension dim = getImageDimension(new ByteArrayInputStream(legendMemoryCache.toByteArray())); if (dim == null) { log.debug("No dimensions could be determined"); } else { lp.setWidth((int) dim.getWidth()); lp.setHeight((int) dim.getHeight()); log.debug(String.format("Dimensions: %d x %d", lp.getWidth(), lp.getHeight())); } } catch (Exception e) { log.warn("Exception loading legend dimensions from URL " + lp.getUrl(), e); } finally { if (in != null) { try { in.close(); } catch (IOException ex) { } } if (fos != null) { try { fos.close(); } catch (IOException ex) { } } } } } }
From source file:press.gfw.Windows.java
private void initWindows() { Dimension dimemsion = Toolkit.getDefaultToolkit().getScreenSize(); setSize(480, 270);/* w w w . jav a 2s . c o m*/ setLocation((int) (dimemsion.getWidth() - getWidth()) / 2, (int) (dimemsion.getHeight() - getHeight()) / 2); // setAlwaysOnTop(true); setResizable(false); addWindowListener(new WindowsListener()); // ? BorderLayout windowsLayout = new BorderLayout(20, 20); setLayout(windowsLayout); }
From source file:org.richfaces.component.InputNumberSliderComponentTest.java
public void testImages() throws Exception { InternetResource image = InternetResourceBuilder.getInstance().createResource(null, SliderFieldGradient.class.getName()); Dimension imageDim = ((Java2Dresource) image).getDimensions(facesContext, null); assertTrue(imageDim.getWidth() == 31 && imageDim.getHeight() == 55); image = InternetResourceBuilder.getInstance().createResource(null, SliderTrackGradient.class.getName()); imageDim = ((Java2Dresource) image).getDimensions(facesContext, null); assertTrue(imageDim.getWidth() == 7 && imageDim.getHeight() == 10); image = InternetResourceBuilder.getInstance().createResource(null, SliderArrowImage.class.getName()); imageDim = ((Java2Dresource) image).getDimensions(facesContext, null); assertTrue(imageDim.getWidth() == 7 && imageDim.getHeight() == 8); image = InternetResourceBuilder.getInstance().createResource(null, SliderArrowSelectedImage.class.getName()); imageDim = ((Java2Dresource) image).getDimensions(facesContext, null); assertTrue(imageDim.getWidth() == 7 && imageDim.getHeight() == 8); }
From source file:de.tor.tribes.ui.algo.TimeFrameVisualizer.java
private void updateSize() { LongRange startRange = mTimeFrame.getStartRange(); LongRange arriveRange = mTimeFrame.getArriveRange(); long minValue = startRange.getMinimumLong(); long maxValue = arriveRange.getMaximumLong(); Dimension size = new Dimension(Math.round( (maxValue - minValue + 240 * (int) DateUtils.MILLIS_PER_MINUTE) / DateUtils.MILLIS_PER_MINUTE), getHeight());//from w w w . j ava 2s . co m if (size.getWidth() < mParent.getWidth()) { size = mParent.getSize(); } setMinimumSize(size); setMaximumSize(size); setPreferredSize(size); mParent.getViewport().setViewSize(size); }
From source file:co.com.soinsoftware.hotelero.view.JFRoomDetail.java
public JFRoomDetail(final JFRoom parent, final InvoiceController invoiceController) throws IOException { this.initComponents(); final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation((int) (screenSize.getWidth() / 2 - 350), (int) (screenSize.getHeight() / 2 - 380)); this.setModal(true); this.parent = parent; this.invoiceController = invoiceController; roomStatusController = new RoomStatusController(); invoiceStatusController = new InvoiceStatusController(); this.roomStatusBooked = roomStatusController.selectBooked(); }
From source file:util.StreamBlobUtil.java
/** * Returns scaled blob/*from w w w .ja v a 2 s . c o m*/ * @param b byte stream * @param width width of the image * @param height height of the image * @param scale boolean yes or no * @return scaled byte stream */ public synchronized byte[] newStreamBlob(byte[] b, int width, int height, boolean doIScale) throws BasicObjException { logger.info("entered 1 streamBlob"); if (b == null) { return null; } logger.info("entered 2 streamBlob"); try { initializeImageInfo(); logger.info("completed new ImageInfo()"); if (info != null) { logger.info("info != null"); //MagickImage image = new MagickImage(info, b); logger.info("completed new MagickImage() in streamBlob"); if (image != null) { image.blobToImage(info, b); MagickImage scaled = null; if (doIScale) { // scale the image Dimension d = image.getDimension(); logger.info("completed new getDimension() in streamBlob"); d = WebUtil.getDimension(d, width, height); logger.info("completed getDimension() in streamBlob"); if (d != null) { scaled = image.scaleImage((int) d.getWidth(), (int) d.getHeight()); } } else { // don't scale the image scaled = image.scaleImage(width, height); } if (scaled != null) { logger.info("completing 4 streamBlob"); return (scaled.imageToBlob(info)); } } } } catch (Exception e) { throw new BasicObjException("Error writing image stream ", e); } logger.info("returning null in streamBlob"); return null; }
From source file:ireport_5_6_0.view.JasperDesignViewer.java
/** This method is called from within the constructor to * initialize the form./*www . jav a2 s . com*/ * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents pnlMain = new javax.swing.JPanel(); setTitle("JasperDesignViewer"); setIconImage( new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/jricon.GIF")) .getImage()); addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent evt) { exitForm(); } }); pnlMain.setLayout(new java.awt.BorderLayout()); getContentPane().add(pnlMain, java.awt.BorderLayout.CENTER); pack(); Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit(); java.awt.Dimension screenSize = toolkit.getScreenSize(); int screenResolution = toolkit.getScreenResolution(); float zoom = ((float) screenResolution) / JRViewer.REPORT_RESOLUTION; int height = (int) (550 * zoom); if (height > screenSize.getHeight()) { height = (int) screenSize.getHeight(); } int width = (int) (750 * zoom); if (width > screenSize.getWidth()) { width = (int) screenSize.getWidth(); } java.awt.Dimension dimension = new java.awt.Dimension(width, height); setSize(dimension); setLocation((screenSize.width - width) / 2, (screenSize.height - height) / 2); }
From source file:org.photovault.swingui.JAIPhotoViewer.java
public void fit() { isFit = true;/*from w ww. j a va 2 s.c o m*/ Dimension displaySize = scrollPane.getSize(); log.debug("fit to " + displaySize.getWidth() + ", " + displaySize.getHeight()); imageView.fitToRect(displaySize.getWidth() - 6, displaySize.getHeight() - 6); }