List of usage examples for java.awt Rectangle Rectangle
public Rectangle(int x, int y, int width, int height)
From source file:omr.sheet.ScaleBuilder.java
/** * Create a scale entity, by processing the provided sheet picture. */// www .java 2 s . c o m private void retrieveScale() { Picture picture = sheet.getPicture(); adapter = new Adapter(sheet, picture.getHeight() - 1); // Read the picture runs RunsBuilder runsBuilder = new RunsBuilder(adapter); runsBuilder.createRuns(new Rectangle(0, 0, picture.getHeight(), picture.getWidth())); logger.info("Scale black is " + mainFore + ", white is " + mainBack + ", interline is " + (mainFore + mainBack)); // Check picture resolution if ((mainFore + mainBack) < constants.minInterline.getValue()) { String msg = "With only " + (mainFore + mainBack) + " pixels between two staff lines," + " your picture resolution is too low!" + "\nPlease rescan at higher resolution (300dpi should be OK)"; logger.warning(msg); if (Main.getGui() != null) { Main.getGui().displayWarning(msg); } } }
From source file:com.github.dougkelly88.FLIMPlateReaderGUI.FLIMClasses.Classes.FindMaxpoint.java
/** * Creates a chart.//from ww w . jav a2 s . c o m * * @param dataset the data for the chart. * * @return a chart. */ public JFreeChart createChart() { //http://www.java2s.com/Code/Java/Chart/JFreeChartDualAxisDemo2.htm String xlabel = "Delay (ps)"; String ylabel = "Signal (DN)"; // create the chart with findmaxpoint results final JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title xlabel, // x axis label ylabel, // y axis label findMaxpointData_, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); final XYPlot plot = chart.getXYPlot(); // deal with axes and add second dataset final NumberAxis yaxis1 = (NumberAxis) plot.getRangeAxis(); yaxis1.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10)); yaxis1.setLabelFont(new Font("Dialog", Font.PLAIN, 10)); final NumberAxis yaxis2 = new NumberAxis(null); final NumberAxis xaxis = (NumberAxis) plot.getDomainAxis(); xaxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10)); xaxis.setLabelFont(new Font("Dialog", Font.PLAIN, 10)); plot.setRangeAxis(1, yaxis2); plot.setDataset(1, gatePositionData_); plot.mapDatasetToRangeAxis(1, 1); yaxis1.setRange(0, 5000); yaxis2.setRange(-1, 1); yaxis2.setTickLabelsVisible(false); xaxis.setRange(0, 16666); // deal with visuals final XYLineAndShapeRenderer renderer1 = new XYLineAndShapeRenderer(true, true); renderer1.setSeriesPaint(0, Color.RED); renderer1.setSeriesStroke(0, new BasicStroke(3)); // renderer1.setBaseShapesVisible(true); // renderer1.setSeriesShape(0, ShapeUtilities.createDiagonalCross(4,1)); plot.setRenderer(0, renderer1); // final StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); final XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(false, true); renderer2.setSeriesPaint(0, Color.CYAN); renderer2.setSeriesShapesFilled(0, Boolean.TRUE); renderer2.setBaseShapesVisible(true); renderer2.setShape(new Rectangle(-2, -100, 4, 200)); renderer2.setOutlineStroke(new BasicStroke(1)); renderer2.setOutlinePaint(Color.GRAY); renderer2.setUseOutlinePaint(true); plot.setRenderer(1, renderer2); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); // return chart; }
From source file:com.funambol.email.admin.EmailSyncSourceConfigPanel.java
/** * Create the panel//from w ww. j a v a 2 s. com */ public void init() { // set layout this.setLayout(null); // set properties of label, position and border // referred to the title of the panel titledBorder1 = new TitledBorder(""); panelName.setFont(titlePanelFont); panelName.setText("Edit Email Connector SyncSource"); panelName.setBounds(new Rectangle(14, 5, 316, 28)); panelName.setAlignmentX(SwingConstants.CENTER); panelName.setBorder(titledBorder1); // -------- sourceUriLabel.setText("Source URI: "); sourceUriLabel.setFont(defaultFont); sourceUriLabel.setBounds(new Rectangle(14, 70, 150, 19)); sourceUriValue.setFont(defaultFont); sourceUriValue.setBounds(new Rectangle(170, 70, 350, 19)); nameLabel.setText("Name: "); nameLabel.setFont(defaultFont); nameLabel.setBounds(new Rectangle(14, 100, 150, 19)); nameValue.setFont(defaultFont); nameValue.setBounds(new Rectangle(170, 100, 350, 19)); infoTypesLabel.setText("Supported Types: "); infoTypesLabel.setFont(defaultFont); infoTypesLabel.setBounds(new Rectangle(14, 130, 150, 19)); infoTypesValue.setFont(defaultFont); infoTypesValue.setBounds(new Rectangle(170, 130, 350, 19)); infoTypesValue.setEnabled(false); infoVersionsLabel.setText("Supported Versions: "); infoVersionsLabel.setFont(defaultFont); infoVersionsLabel.setBounds(new Rectangle(14, 160, 150, 19)); infoVersionsValue.setFont(defaultFont); infoVersionsValue.setBounds(new Rectangle(170, 160, 350, 19)); infoVersionsValue.setEnabled(false); dtEncryptLabel.setText("Encryption: "); dtEncryptLabel.setFont(defaultFont); dtEncryptLabel.setBounds(new Rectangle(14, 190, 150, 18)); dtEncryptValue.setSelected(false); dtEncryptValue.setBounds(new Rectangle(166, 190, 25, 19)); contentProviderURLLabel.setText("Content Provider URL: "); contentProviderURLLabel.setFont(defaultFont); contentProviderURLLabel.setBounds(new Rectangle(14, 250, 150, 19)); contentProviderURLValue.setFont(defaultFont); contentProviderURLValue.setBounds(new Rectangle(170, 250, 350, 19)); signatureLabel.setText("Funambol Signature: "); signatureLabel.setFont(defaultFont); signatureLabel.setBounds(new Rectangle(14, 220, 150, 19)); signatureValue.setFont(defaultFont); signatureValue.setBounds(new Rectangle(170, 220, 350, 19)); confirmButton.setFont(defaultFont); confirmButton.setText("Add"); confirmButton.setBounds(170, 280, 70, 25); confirmButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { validateValues(); getValues(); if (getState() == STATE_INSERT) { EmailSyncSourceConfigPanel.this.actionPerformed(new ActionEvent( EmailSyncSourceConfigPanel.this, ACTION_EVENT_INSERT, event.getActionCommand())); } else { EmailSyncSourceConfigPanel.this.actionPerformed(new ActionEvent( EmailSyncSourceConfigPanel.this, ACTION_EVENT_UPDATE, event.getActionCommand())); } } catch (Exception e) { notifyError(new AdminException(e.getMessage())); } } }); // add all components to the panel this.add(panelName, null); this.add(sourceUriLabel, null); this.add(sourceUriValue, null); this.add(nameLabel, null); this.add(nameValue, null); this.add(infoTypesLabel, null); this.add(infoTypesValue, null); this.add(infoVersionsLabel, null); this.add(infoVersionsValue, null); this.add(dtEncryptLabel, null); this.add(dtEncryptValue, null); // Uncomment the next two lines if you want to show the Content Provider URL // input field //this.add(contentProviderURLLabel, null); //this.add(contentProviderURLValue, null); this.add(signatureLabel, null); this.add(signatureValue, null); this.add(confirmButton, null); }
From source file:com.funambol.admin.settings.panels.EditDailyRollingFileAppender.java
/** * Create the panel//from w ww . j a v a 2 s.c om * @throws Exception if error occures during creation of the panel. */ private void init() throws Exception { final int h = 18; final int x1 = 15; final int x2 = 150; final int w1 = 100; final int w2 = 310; int y = 40; int dy = 25; setLayout(null); setName(Bundle.getMessage(Bundle.EDIT_DAILY_ROLLING_FILE_APPENDER_PANEL_NAME)); panelNameLabel.setText(Bundle.getMessage(Bundle.EDIT_DAILY_ROLLING_FILE_APPENDER_PANEL_NAME)); panelNameLabel.setBounds(new Rectangle(14, 5, 290, 28)); panelNameLabel.setAlignmentX(SwingConstants.CENTER); panelNameLabel.setBorder(new TitledBorder("")); nameLabel.setText(Bundle.getMessage(Bundle.LABEL_APPENDER_NAME) + " :"); nameLabel.setBounds(new Rectangle(x1, y, w1, h)); nameLabel2.setBounds(new Rectangle(x2, y, w2, h)); y += dy; fileNameLabel.setText(Bundle.getMessage(Bundle.LABEL_FILE_NAME) + " :"); fileNameLabel.setBounds(new Rectangle(x1, y, w1, h)); fileNameValue.setBounds(new Rectangle(x2, y, w2, h)); y += dy; datePatternLabel.setText(Bundle.getMessage(Bundle.LABEL_DATE_PATTERN) + " :"); datePatternLabel.setBounds(new Rectangle(x1, y, w1, h)); datePatternValue.setBounds(new Rectangle(x2, y, w2, h)); datePatternValue.setHorizontalAlignment(JTextField.RIGHT); y += dy; conversionPatternLabel.setText(Bundle.getMessage(Bundle.LABEL_PATTERN_LAYOUT) + " :"); conversionPatternLabel.setBounds(new Rectangle(x1, y, w1, h)); conversionPattern.setBounds(new Rectangle(x2, y, w2, h)); y += dy; noteLabel.setText(Bundle.getMessage(Bundle.LABEL_FILE_APPENDER_NOTE)); noteLabel.setBounds(new Rectangle(x1, y, 500, h)); y += dy; y += dy; confirmButton.setText(Bundle.getMessage(Bundle.LABEL_BUTTON_SAVE)); confirmButton.setBounds(new Rectangle(401, y, 60, 25)); confirmButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { validateValues(); getValues(); EditDailyRollingFileAppender.this.actionPerformed(new ActionEvent( EditDailyRollingFileAppender.this, ACTION_EVENT_UPDATE, event.getActionCommand())); } catch (Exception e) { notifyError(new AdminException(e.getMessage())); } } }); add(panelNameLabel, null); add(nameLabel, null); add(nameLabel2, null); add(fileNameLabel, null); add(fileNameValue, null); add(datePatternLabel, null); add(datePatternValue, null); add(conversionPatternLabel, null); add(conversionPattern, null); add(noteLabel, null); add(confirmButton, null); GuiFactory.setDefaultFont(this); panelNameLabel.setFont(GuiFactory.titlePanelFont); }
From source file:net.rptools.tokentool.ui.TokenCompositionPanel.java
private void paintOverlay(Graphics g, Dimension size) { if (composedOverlayImage == null) { composedOverlayImage = TokenCompositor.translateOverlay(overlayImage, 1); fireCompositionChanged();// w ww .j a va 2 s .c o m } if (composedOverlayImage != null) { int width = (Integer) TokenTool.getFrame().getControlPanel().getWidthSpinner().getValue(); int height = (Integer) TokenTool.getFrame().getControlPanel().getHeightSpinner().getValue(); int x = (size.width - width) / 2; int y = (size.height - height) / 2; if (overlayBounds != null) { if (overlayBounds.width != width || overlayBounds.height != height) { fireCompositionChanged(); } } g.drawImage(composedOverlayImage, x, y, width, height, this); overlayBounds = new Rectangle(x, y, width, height); } }
From source file:juicebox.tools.utils.juicer.apa.APAPlotter.java
/** * @param g2 graphics2D object/* w w w.j ava 2 s. c o m*/ */ private static void plotColorScaleBar(Graphics2D g2) { // calculate color scale bar dimensions & location Point csBarTL = new Point(heatmapWidth + colorScaleHorizontalMargin, colorScaleVerticalMargin); Point csBarBL = new Point(heatmapWidth + colorScaleHorizontalMargin, fullHeight - colorScaleVerticalMargin); Rectangle csBar = new Rectangle(csBarTL.x, csBarTL.y, colorScaleWidth - 2 * colorScaleHorizontalMargin, fullHeight - 2 * colorScaleVerticalMargin); // plot the color scale linear gradient LinearGradientPaint gradient = new LinearGradientPaint(csBarTL, csBarBL, gradientFractions, gradientColors); g2.setPaint(gradient); g2.fill(csBar); // plot a border around color scale g2.setColor(Color.black); g2.drawRect(csBar.x, csBar.y, csBar.width, csBar.height); }
From source file:OughtaFocus.java
public double fullFocus() throws MMException { startTimeMs_ = System.currentTimeMillis(); applySettings();// w w w . j ava 2 s. c o m try { Rectangle oldROI = app_.getROI(); CMMCore core = app_.getMMCore(); liveModeOn_ = app_.isLiveModeOn(); //ReportingUtils.logMessage("Original ROI: " + oldROI); int w = (int) (oldROI.width * cropFactor); int h = (int) (oldROI.height * cropFactor); int x = oldROI.x + (oldROI.width - w) / 2; int y = oldROI.y + (oldROI.height - h) / 2; Rectangle newROI = new Rectangle(x, y, w, h); //ReportingUtils.logMessage("Setting ROI to: " + newROI); Configuration oldState = null; if (channel.length() > 0) { String chanGroup = core.getChannelGroup(); oldState = core.getConfigGroupState(chanGroup); core.setConfig(chanGroup, channel); } // avoid wasting time on setting roi if it is the same if (cropFactor < 1.0) { app_.setROI(newROI); core.waitForDevice(core.getCameraDevice()); } double oldExposure = core.getExposure(); core.setExposure(exposure); double z = runAutofocusAlgorithm(); if (cropFactor < 1.0) { app_.setROI(oldROI); core.waitForDevice(core.getCameraDevice()); } if (oldState != null) { core.setSystemState(oldState); } core.setExposure(oldExposure); setZPosition(z); return z; } catch (Exception ex) { throw new MMException(ex.getMessage()); } }
From source file:Main.java
@Override public boolean isCellEditable(EventObject e) { if (e instanceof MouseEvent && e.getSource() instanceof JTree) { MouseEvent me = (MouseEvent) e; JTree tree = (JTree) e.getSource(); TreePath path = tree.getPathForLocation(me.getX(), me.getY()); Rectangle r = tree.getPathBounds(path); if (r == null) { return false; }//from ww w . j a va 2 s . c o m Dimension d = check.getPreferredSize(); r.setSize(new Dimension(d.width, r.height)); if (r.contains(me.getX(), me.getY())) { check.setBounds(new Rectangle(0, 0, d.width, r.height)); return true; } } return false; }
From source file:com.robertolosanno.cdt_maven.Cdt.java
public Cdt() { //Ontologia/* www.j a v a 2 s . co m*/ OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); loadModel(m); ExtendedIterator<OntClass> iter = m.listHierarchyRootClasses(); // create a simple graph graph = new DelegateTree<String, String>(); createTree(iter); //Vincoli System.out.println("--- CONSTRAINTS ---"); ExtendedIterator<ObjectProperty> iterProp = m.listObjectProperties(); while (iterProp.hasNext()) { ObjectProperty objProp = iterProp.next(); plotConstraint(objProp); } treeLayout = new TreeLayout<String, String>(graph); vv = new VisualizationViewer<String, String>(treeLayout, new Dimension(1200, 600)); vv.setBackground(Color.white); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray)); //***************** MODIFICA COLORE VERTICE ************************ Transformer<String, Paint> vertexColor = new Transformer<String, Paint>() { public Paint transform(String s) { String[] ss = s.split("#"); String type = ss[1]; if (type.equals("root")) return Color.lightGray; if (type.equals("dim")) return Color.BLACK; if (type.equals("val")) return Color.WHITE; if (type.equals("par_val")) return Color.WHITE; if (type.equals("par_dim")) return Color.WHITE; return Color.GREEN; } }; vv.getRenderContext().setVertexFillPaintTransformer(vertexColor); //**************** MODIFICA FORMA VERTICE *************************** //Dati per creare un triangolo (lo creaiamo attraverso la classe Polygon) final int[] xShape = new int[4]; final int[] yShape = new int[4]; final int nShape; // count of points // Make a shape xShape[0] = -10; xShape[1] = 0; xShape[2] = 10; yShape[0] = 0; yShape[1] = 20; yShape[2] = 0; nShape = 3; Transformer<String, Shape> vertexShape = new Transformer<String, Shape>() { private final Shape[] styles = { new Rectangle(-10, -10, 20, 20), new Ellipse2D.Double(-10, -10, 20, 20), new Polygon(xShape, yShape, nShape) //Triangolo }; @Override public Shape transform(String i) { String[] type = i.split("#"); if (type[1].equals("par_val")) { return styles[0]; } else if (type[1].equals("par_dim")) { return styles[2]; } else { return styles[1]; } } }; vv.getRenderContext().setVertexShapeTransformer(vertexShape); // vv.getRenderer().setVertexRenderer(new MyRenderer()); //**************** MODIFICA FONT LABEL *************************** vv.getRenderContext().setVertexFontTransformer(new Transformer<String, Font>() { @Override public Font transform(String arg0) { Font font = new Font("Arial Unicode MS", Font.PLAIN, 11); return font; } }); // ********************** POSIZIONA LA LABEL SOTTO IL VERTICE **************************** vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.S); //******************** RIMUOVE DAL TESTO DELLA LABEL DEL VERTICE IL TIPO DI VERTICE ************************ Transformer<String, String> transformer = new Transformer<String, String>() { @Override public String transform(String arg0) { String[] node = arg0.split("#"); return node[0]; } }; vv.getRenderContext().setVertexLabelTransformer(transformer); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(graphMouse.getModeListener()); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(scaleGrid); controls.add(modeBox); content.add(controls, BorderLayout.SOUTH); }
From source file:gavisualizer.LineChart.java
@Override public void saveAsSVG(String path, int width, int height) throws IOException { // Save image as SVG SVGGraphics2D g2 = new SVGGraphics2D(width, height); Rectangle r = new Rectangle(0, 0, width, height); _chart.draw(g2, r);//from w ww . jav a 2 s .c o m File f = new File(path); SVGUtils.writeToSVG(f, g2.getSVGElement()); }