List of usage examples for java.awt Dimension getHeight
public double getHeight()
From source file:figs.treeVisualization.gui.TimeAxisTree2DPanel.java
/** * Paint this Component using the Tree2DPainter with TimeBars * * @param g the graphics device/*from w w w . ja v a 2s .c o m*/ */ @Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g.create(); /** * Enable antialiased graphics. */ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); Dimension currentSize = this.getSize(); /** * Check to see if this component has changed size or if this * is our first time drawing. */ if (this.fDimension == null || !this.fDimension.equals(currentSize) || this.fTreeArea == null || this.fLeftTreeArea == null || this.fEstMaxDateWidth == null) { this.fDimension = currentSize; this.fTreeArea = new Rectangle2D.Double(0, 0, currentSize.getWidth(), currentSize.getHeight()); /** Adjust the width ratio using the maximum date width. */ this.refreshLeafNodes(); this.estimateMaximumDateWidth(g2); if ((this.fEstMaxDateWidth * 2) > (this.fTreeArea.getWidth() * this.fTreeWidthRatio) - this.fTreeArea.getWidth()) { this.fTreeWidthRatio = (this.fTreeArea.getWidth() - (this.fEstMaxDateWidth * 2)) / this.fTreeArea.getWidth(); } /** Make left tree area for tree. */ this.fLeftTreeArea = new Rectangle2D.Double(0, 0, this.fTreeArea.getWidth() * this.fTreeWidthRatio, this.fTreeArea.getHeight()); /** Now, clear the right tree area so that it will be recalculated. */ this.fRightTreeArea = null; } /** Paint the tree. */ this.fTreePainter.drawTree(g2, this.fLeftTreeArea); /** * Check to see if we have calculated the date data. * The order of this is very important. We need to have * called the painter before we can get the coordinates. */ if (this.fLeafNodes.isEmpty() || this.fLeafDates.isEmpty()) /** Just calculate the Leaf data. */ this.refreshLeafNodes(); /** * Draw the date axis and lines to the leaf nodes. */ if (fTopLeafDate != null || fBottomLeafDate != null) { if (this.fRightTreeArea == null) { calculateDateMargins(); this.fRightTreeArea = new Rectangle2D.Double(this.fTreeArea.getWidth() * this.fTreeWidthRatio, this.fTopLeafPt.getY(), this.fTreeArea.getWidth(), this.fBottomLeafPt.getY()); } double cursor = this.fRightTreeArea.getX() + ((this.fRightTreeArea.getWidth() - this.fRightTreeArea.getX()) / 2); drawDateAxis(g2, cursor, this.fRightTreeArea); drawDatesToLeafs(g2, cursor, this.fRightTreeArea); } else { // g2."No TIME INFORMATION AVAILABLE // g2.drawString("NO TIME INFORMATION AVAILABLE", x, y); System.out.println("TimeBarPanel: No time information available!"); } if (this.fMousePressed && this.fMouseSelectionRect != null) { /** Color of line varies depending on image colors. */ g2.setXORMode(Color.white); g2.drawRect(this.fMouseSelectionRect.x, this.fMouseSelectionRect.y, this.fMouseSelectionRect.width - 1, this.fMouseSelectionRect.height - 1); } }
From source file:org.geoserver.wms.legendgraphic.ColorMapLegendCreator.java
private Queue<BufferedImage> createFooter() { // creating a backbuffer image on which we should draw the bkgColor for this colormap element final BufferedImage image = ImageUtils.createImage(1, 1, (IndexColorModel) null, transparent); final Map<Key, Object> hintsMap = new HashMap<Key, Object>(); final Graphics2D graphics = ImageUtils.prepareTransparency(transparent, backgroundColor, image, hintsMap); // list where we store the rows for the footer final Queue<BufferedImage> queue = new LinkedList<BufferedImage>(); // //the height is already fixed // final int rowHeight=(int)Math.round(rowH); final int rowWidth = (int) Math.round(footerW); // final Rectangle clipboxA=new Rectangle(0,0,rowWidth,rowHeight); ////from w w w . ja v a 2s. c o m // footer // // // draw the various bodyCells for (Cell cell : footerRows) { // get dim final Dimension dim = cell.getPreferredDimension(graphics); // final int rowWidth=(int)Math.round(dim.getWidth()); final int rowHeight = (int) Math.round(dim.getHeight()); final Rectangle clipboxA = new Rectangle(0, 0, rowWidth, rowHeight); // draw it final BufferedImage colorCellLegend = new BufferedImage(rowWidth, rowHeight, BufferedImage.TYPE_INT_ARGB); Graphics2D rlg = colorCellLegend.createGraphics(); rlg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); cell.draw(rlg, clipboxA, border); rlg.dispose(); queue.add(colorCellLegend); } graphics.dispose(); return queue;// mergeRows(queue); }
From source file:org.apache.jmeter.visualizers.RespTimeGraphVisualizer.java
public void makeGraph() { Dimension size = graphPanel.getSize(); // canvas size int width = (int) size.getWidth(); int height = (int) size.getHeight(); if (!dynamicGraphSize.isSelected()) { String wstr = graphWidth.getText(); String hstr = graphHeight.getText(); if (wstr.length() != 0) { width = Integer.parseInt(wstr); }//from w w w . ja va 2 s. c o m if (hstr.length() != 0) { height = Integer.parseInt(hstr); } } String yAxisStr = maxValueYAxisLabel.getText(); int maxYAxisScale = yAxisStr.length() == 0 ? 0 : Integer.parseInt(yAxisStr); graphPanel.setData(this.getData()); graphPanel.setTitle(graphTitle.getText()); graphPanel.setMaxYAxisScale(maxYAxisScale); graphPanel.setYAxisLabels(Y_AXIS_LABEL); graphPanel.setYAxisTitle(Y_AXIS_TITLE); graphPanel.setXAxisLabels(getXAxisLabels()); graphPanel.setLegendLabels(getLegendLabels()); graphPanel.setColor(getLinesColors()); graphPanel.setShowGrouping(numberShowGrouping.isSelected()); graphPanel.setLegendPlacement( StatGraphProperties.getPlacementNameMap().get(legendPlacementList.getSelectedItem()).intValue()); graphPanel.setPointShape(StatGraphProperties.getPointShapeMap().get(pointShapeLine.getSelectedItem())); graphPanel.setStrokeWidth(Float.parseFloat((String) strokeWidthList.getSelectedItem())); graphPanel.setTitleFont( new Font(StatGraphProperties.getFontNameMap().get(titleFontNameList.getSelectedItem()), StatGraphProperties.getFontStyleMap().get(titleFontStyleList.getSelectedItem()).intValue(), Integer.parseInt((String) titleFontSizeList.getSelectedItem()))); graphPanel.setLegendFont(new Font(StatGraphProperties.getFontNameMap().get(fontNameList.getSelectedItem()), StatGraphProperties.getFontStyleMap().get(fontStyleList.getSelectedItem()).intValue(), Integer.parseInt((String) fontSizeList.getSelectedItem()))); graphPanel.setHeight(height); graphPanel.setWidth(width); graphPanel.setIncrYAxisScale(getIncrScaleYAxis()); // Draw the graph graphPanel.repaint(); }
From source file:de.bfs.radon.omsimulation.gui.OMPanelData.java
/** * Initialises the interface of the data panel. *//*from w w w . j ava 2 s .com*/ protected void initialize() { setLayout(null); lblExportChartTo = new JLabel("Export chart to ..."); lblExportChartTo.setBounds(436, 479, 144, 14); lblExportChartTo.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); lblExportChartTo.setVisible(false); add(lblExportChartTo); btnCsv = new JButton("CSV"); btnCsv.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fileDialog = new JFileChooser(); fileDialog.setFileFilter(new FileNameExtensionFilter("*.csv", "csv")); fileDialog.showSaveDialog(getParent()); final File file = fileDialog.getSelectedFile(); if (file != null) { String csv; String[] tmpFileName = file.getAbsolutePath().split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("csv")) { csv = ""; } else { csv = ".csv"; } String csvPath = file.getAbsolutePath() + csv; OMRoom selectedRoom = (OMRoom) comboBoxRooms.getSelectedItem(); double[] selectedValues = selectedRoom.getValues(); File csvFile = new File(csvPath); try { FileWriter logWriter = new FileWriter(csvFile); BufferedWriter csvOutput = new BufferedWriter(logWriter); csvOutput.write("\"ID\";\"" + selectedRoom.getId() + "\""); csvOutput.newLine(); for (int i = 0; i < selectedValues.length; i++) { csvOutput.write("\"" + i + "\";\"" + (int) selectedValues[i] + "\""); csvOutput.newLine(); } JOptionPane.showMessageDialog(null, "CSV saved successfully!\n" + csvPath, "Success", JOptionPane.INFORMATION_MESSAGE); csvOutput.close(); } catch (IOException ioe) { JOptionPane.showMessageDialog(null, "Failed to write CSV. Please check permissions!\n" + ioe.getMessage(), "Failed", JOptionPane.ERROR_MESSAGE); ioe.printStackTrace(); } } else { JOptionPane.showMessageDialog(null, "Failed to write CSV. Please check the file path!", "Failed", JOptionPane.ERROR_MESSAGE); } } }); btnCsv.setBounds(590, 475, 70, 23); btnCsv.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); btnCsv.setVisible(false); add(btnCsv); btnPdf = new JButton("PDF"); btnPdf.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fileDialog = new JFileChooser(); fileDialog.setFileFilter(new FileNameExtensionFilter("*.pdf", "pdf")); fileDialog.showSaveDialog(getParent()); final File file = fileDialog.getSelectedFile(); if (file != null) { String pdf; String[] tmpFileName = file.getAbsolutePath().split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("pdf")) { pdf = ""; } else { pdf = ".pdf"; } String pdfPath = file.getAbsolutePath() + pdf; OMBuilding building = (OMBuilding) comboBoxProjects.getSelectedItem(); String title = building.getName(); OMRoom selectedRoom = (OMRoom) comboBoxRooms.getSelectedItem(); JFreeChart chart = OMCharts.createRoomChart(title, selectedRoom, false); int height = (int) PageSize.A4.getWidth(); int width = (int) PageSize.A4.getHeight(); try { OMExports.exportPdf(pdfPath, chart, width, height, new DefaultFontMapper(), title); JOptionPane.showMessageDialog(null, "PDF saved successfully!\n" + pdfPath, "Success", JOptionPane.INFORMATION_MESSAGE); } catch (IOException ioe) { JOptionPane.showMessageDialog(null, "Failed to write PDF. Please check permissions!\n" + ioe.getMessage(), "Failed", JOptionPane.ERROR_MESSAGE); ioe.printStackTrace(); } } else { JOptionPane.showMessageDialog(null, "Failed to write PDF. Please check the file path!", "Failed", JOptionPane.ERROR_MESSAGE); } } }); btnPdf.setBounds(670, 475, 70, 23); btnPdf.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); btnPdf.setVisible(false); add(btnPdf); lblSelectProject = new JLabel("Select Project"); lblSelectProject.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); lblSelectProject.setBounds(10, 65, 132, 14); add(lblSelectProject); lblSelectRoom = new JLabel("Select Room"); lblSelectRoom.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); lblSelectRoom.setBounds(10, 94, 132, 14); add(lblSelectRoom); panelData = new JPanel(); panelData.setBounds(10, 118, 730, 347); add(panelData); btnRefresh = new JButton("Load"); btnRefresh.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); btnRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (txtOmbFile.getText() != null && !txtOmbFile.getText().equals("") && !txtOmbFile.getText().equals(" ")) { txtOmbFile.setBackground(Color.WHITE); String ombPath = txtOmbFile.getText(); String omb; String[] tmpFileName = ombPath.split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("omb")) { omb = ""; } else { omb = ".omb"; } txtOmbFile.setText(ombPath + omb); setOmbFile(ombPath + omb); File ombFile = new File(ombPath + omb); if (ombFile.exists()) { txtOmbFile.setBackground(Color.WHITE); btnRefresh.setEnabled(false); comboBoxProjects.setEnabled(false); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); btnPdf.setVisible(false); btnCsv.setVisible(false); lblExportChartTo.setVisible(false); progressBar.setVisible(true); progressBar.setStringPainted(true); progressBar.setIndeterminate(true); refreshProjectsTask = new RefreshProjects(); refreshProjectsTask.execute(); } else { txtOmbFile.setBackground(new Color(255, 222, 222, 128)); JOptionPane.showMessageDialog(null, "OMB-file not found, please check the file path!", "Error", JOptionPane.ERROR_MESSAGE); } } else { txtOmbFile.setBackground(new Color(255, 222, 222, 128)); JOptionPane.showMessageDialog(null, "Please select an OMB-file!", "Warning", JOptionPane.WARNING_MESSAGE); } } }); btnRefresh.setBounds(616, 61, 124, 23); add(btnRefresh); btnMaximize = new JButton("Fullscreen"); btnMaximize.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); btnMaximize.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (comboBoxRooms.isEnabled()) { if (comboBoxRooms.getSelectedItem() != null) { OMBuilding building = (OMBuilding) comboBoxProjects.getSelectedItem(); String title = building.getName(); OMRoom room = (OMRoom) comboBoxRooms.getSelectedItem(); panelRoom = createRoomPanel(title, room, false, false); JFrame chartFrame = new JFrame(); JPanel chartPanel = createRoomPanel(title, room, false, true); chartFrame.getContentPane().add(chartPanel); chartFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); chartFrame.setBounds(0, 0, (int) dim.getWidth(), (int) dim.getHeight()); chartFrame.setTitle("OM Simulation Tool: " + title + ", Room " + room.getId()); chartFrame.setResizable(true); chartFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); chartFrame.setVisible(true); } } } }); btnMaximize.setBounds(10, 475, 124, 23); btnMaximize.setVisible(false); add(btnMaximize); comboBoxProjects = new JComboBox<OMBuilding>(); comboBoxProjects.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); comboBoxProjects.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { boolean b = false; Color c = null; if (comboBoxProjects.isEnabled()) { if (comboBoxProjects.getSelectedItem() != null) { b = true; c = Color.WHITE; OMBuilding building = (OMBuilding) comboBoxProjects.getSelectedItem(); comboBoxRooms.removeAllItems(); for (int i = 0; i < building.getRooms().length; i++) { comboBoxRooms.addItem(building.getRooms()[i]); } for (int i = 0; i < building.getCellars().length; i++) { comboBoxRooms.addItem(building.getCellars()[i]); } for (int i = 0; i < building.getMiscs().length; i++) { comboBoxRooms.addItem(building.getMiscs()[i]); } } else { b = false; c = null; } } else { b = false; c = null; } lblSelectRoom.setEnabled(b); panelData.setEnabled(b); btnMaximize.setVisible(b); comboBoxRooms.setEnabled(b); panelData.setBackground(c); } }); comboBoxProjects.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { boolean b = false; Color c = null; if (comboBoxProjects.isEnabled()) { if (comboBoxProjects.getSelectedItem() != null) { b = true; c = Color.WHITE; OMBuilding building = (OMBuilding) comboBoxProjects.getSelectedItem(); comboBoxRooms.removeAllItems(); for (int i = 0; i < building.getRooms().length; i++) { comboBoxRooms.addItem(building.getRooms()[i]); } for (int i = 0; i < building.getCellars().length; i++) { comboBoxRooms.addItem(building.getCellars()[i]); } for (int i = 0; i < building.getMiscs().length; i++) { comboBoxRooms.addItem(building.getMiscs()[i]); } } else { b = false; c = null; } } else { b = false; c = null; } lblSelectRoom.setEnabled(b); panelData.setEnabled(b); btnMaximize.setVisible(b); comboBoxRooms.setEnabled(b); panelData.setBackground(c); } }); comboBoxProjects.setBounds(152, 61, 454, 22); add(comboBoxProjects); comboBoxRooms = new JComboBox<OMRoom>(); comboBoxRooms.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); comboBoxRooms.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (comboBoxRooms.isEnabled()) { if (comboBoxRooms.getSelectedItem() != null) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); remove(panelData); comboBoxRooms.setEnabled(false); refreshChartsTask = new RefreshCharts(); refreshChartsTask.execute(); } } } }); comboBoxRooms.setBounds(152, 90, 454, 22); add(comboBoxRooms); progressBar = new JProgressBar(); progressBar.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); progressBar.setBounds(10, 475, 730, 23); progressBar.setVisible(false); add(progressBar); lblSelectRoom.setEnabled(false); panelData.setEnabled(false); comboBoxRooms.setEnabled(false); lblHelp = new JLabel( "Select an OMB-Object file to analyse its data. You can inspect radon concentration for each room."); lblHelp.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); lblHelp.setForeground(Color.GRAY); lblHelp.setBounds(10, 10, 730, 14); add(lblHelp); txtOmbFile = new JTextField(); txtOmbFile.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); txtOmbFile.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent arg0) { setOmbFile(txtOmbFile.getText()); } }); txtOmbFile.setBounds(152, 33, 454, 20); add(txtOmbFile); txtOmbFile.setColumns(10); btnBrowse = new JButton("Browse"); btnBrowse.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); btnBrowse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { JFileChooser fileDialog = new JFileChooser(); fileDialog.setFileFilter(new FileNameExtensionFilter("*.omb", "omb")); fileDialog.showOpenDialog(getParent()); final File file = fileDialog.getSelectedFile(); if (file != null) { String omb; String[] tmpFileName = file.getAbsolutePath().split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("omb")) { omb = ""; } else { omb = ".omb"; } txtOmbFile.setText(file.getAbsolutePath() + omb); setOmbFile(file.getAbsolutePath() + omb); } } }); btnBrowse.setBounds(616, 32, 124, 23); add(btnBrowse); lblSelectOmbfile = new JLabel("Select OMB-File"); lblSelectOmbfile.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); lblSelectOmbfile.setBounds(10, 36, 132, 14); add(lblSelectOmbfile); }
From source file:io.github.dsheirer.spectrum.SpectrumPanel.java
/** * Draws the current fft spectrum with a line and a gradient fill. *///from ww w .j a va 2s. c om private void drawSpectrum(Graphics2D graphics) { Dimension size = getSize(); //Draw the background Rectangle background = new Rectangle(0, 0, size.width, size.height); graphics.setColor(mColorSpectrumBackground); graphics.draw(background); graphics.fill(background); //Define the gradient GradientPaint gradient = new GradientPaint(0, (getSize().height - mSpectrumInset) / 2, mColorSpectrumGradientTop, 0, getSize().height, mColorSpectrumGradientBottom); graphics.setBackground(mColorSpectrumBackground); GeneralPath spectrumShape = new GeneralPath(); //Start at the lower right inset point spectrumShape.moveTo(size.getWidth(), size.getHeight() - mSpectrumInset); //Draw to the lower left spectrumShape.lineTo(0, size.getHeight() - mSpectrumInset); float[] bins = getBins(); //If we have FFT data to display ... if (bins != null) { float insideHeight = size.height - mSpectrumInset; float scalor = insideHeight / -mDBScale; /* Calculate based on bin size - 1, since bin 0 is rendered at zero * and the last bin is rendered at the width */ float binSize = (float) size.width / ((float) (bins.length)); for (int x = 0; x < bins.length; x++) { float height; height = bins[x] * scalor; if (height > insideHeight) { height = insideHeight; } if (height < 0) { height = 0; } float xAxis = (float) x * binSize; spectrumShape.lineTo(xAxis, height); } } //Otherwise show an empty spectrum else { //Draw Left Size graphics.setPaint(gradient); spectrumShape.lineTo(0, size.getHeight() - mSpectrumInset); //Draw Middle spectrumShape.lineTo(size.getWidth(), size.getHeight() - mSpectrumInset); } //Draw Right Side spectrumShape.lineTo(size.getWidth(), size.getHeight() - mSpectrumInset); graphics.setPaint(gradient); graphics.draw(spectrumShape); graphics.fill(spectrumShape); graphics.setPaint(mColorSpectrumLine); //Draw the bottom line under the spectrum graphics.draw(new Line2D.Float(0, size.height - mSpectrumInset, size.width, size.height - mSpectrumInset)); }
From source file:VerticalFlowLayout.java
/** * Description of the Method// w ww . j a v a 2 s . c o m * *@param target Description of Parameter */ public void layoutContainer(Container target) { synchronized (target.getTreeLock()) { Insets insets = target.getInsets(); int maxheight = target.getHeight() - (insets.top + insets.bottom + _vgap * 2); int nmembers = target.getComponentCount(); int y = 0; Dimension preferredSize = preferredLayoutSize(target); Dimension targetSize = target.getSize(); switch (_valign) { case TOP: y = insets.top; break; case CENTER: y = (targetSize.height - preferredSize.height) / 2; break; case BOTTOM: y = targetSize.height - preferredSize.height - insets.bottom; break; } for (int i = 0; i < nmembers; i++) { Component m = target.getComponent(i); if (m.isVisible()) { Dimension d = m.getPreferredSize(); m.setSize(d.width, d.height); if ((y + d.height) <= maxheight) { if (y > 0) { y += _vgap; } int x = 0; switch (_halign) { case LEFT: x = insets.left; break; case CENTER: x = (targetSize.width - d.width) / 2; break; case RIGHT: x = targetSize.width - d.width - insets.right; break; } m.setLocation(x, y); y += d.getHeight(); } else { break; } } } } }
From source file:com.igormaznitsa.sciareto.ui.editors.MMDEditor.java
public void topicToCentre(@Nullable final Topic topic) { if (topic != null) { SwingUtilities.invokeLater(new Runnable() { @Override/*from w w w.j a v a 2 s. co m*/ public void run() { final AbstractElement element = (AbstractElement) Assertions.assertNotNull(topic).getPayload(); if (element != null) { final Rectangle2D bounds = element.getBounds(); final Dimension viewPortSize = getViewport().getExtentSize(); final int x = Math.max(0, (int) Math .round(bounds.getX() - (viewPortSize.getWidth() - bounds.getWidth()) / 2)); final int y = Math.max(0, (int) Math .round(bounds.getY() - (viewPortSize.getHeight() - bounds.getHeight()) / 2)); getViewport().setViewPosition(new Point(x, y)); } } }); } }
From source file:metdemo.Finance.SHNetworks.java
/** * This method does..//from www . j a va 2s.c o m * */ protected void moveVertices() { // first, organize the vertices by SocialScore Level (5 different // stages) HashMap<Integer, ArrayList<VIPVertex>> levels = stepDivide(SHNetworks.STRAIGHT_SCALE); // next, place the vertices according to their echelon Iterator levelIter = levels.keySet().iterator(); while (levelIter.hasNext()) { // first, get critical objects/information for the current level Integer level = (Integer) levelIter.next(); ArrayList<VIPVertex> verts = levels.get(level); int numVerts = verts.size(); // next, get the dimension attributes of the current window Dimension winSize = m_layout.getCurrentSize(); double winHeight = winSize.getHeight(); double winWidth = winSize.getWidth(); // then, place each of the vertices according window/level size double curY = (winHeight / 6) * level + 20; double xInc = winWidth / (numVerts + 1); double curX = xInc; Iterator vertIter = verts.iterator(); while (vertIter.hasNext()) { VIPVertex vert = (VIPVertex) vertIter.next(); m_layout.forceMove(vert, curX, curY); curX += xInc; } } }
From source file:org.apache.jmeter.visualizers.StatGraphVisualizer.java
public void makeGraph() { nbColToGraph = getNbColumns();/*from w w w . j av a 2s . c o m*/ Dimension size = graphPanel.getSize(); String lstr = maxLengthXAxisLabel.getText(); // canvas size int width = (int) size.getWidth(); int height = (int) size.getHeight(); if (!dynamicGraphSize.isSelected()) { String wstr = graphWidth.getText(); String hstr = graphHeight.getText(); if (wstr.length() != 0) { width = Integer.parseInt(wstr); } if (hstr.length() != 0) { height = Integer.parseInt(hstr); } } if (lstr.length() == 0) { lstr = "20";//$NON-NLS-1$ } int maxLength = Integer.parseInt(lstr); String yAxisStr = maxValueYAxisLabel.getText(); int maxYAxisScale = yAxisStr.length() == 0 ? 0 : Integer.parseInt(yAxisStr); graphPanel.setData(this.getData()); graphPanel.setTitle(graphTitle.getText()); graphPanel.setMaxLength(maxLength); graphPanel.setMaxYAxisScale(maxYAxisScale); graphPanel.setXAxisLabels(getAxisLabels()); graphPanel.setXAxisTitle(JMeterUtils.getResString((String) columnsList.getSelectedItem())); graphPanel.setYAxisLabels(this.yAxisLabel); graphPanel.setYAxisTitle(this.yAxisTitle); graphPanel.setLegendLabels(getLegendLabels()); graphPanel.setColor(getBackColors()); graphPanel.setForeColor(colorForeGraph); graphPanel.setOutlinesBarFlag(drawOutlinesBar.isSelected()); graphPanel.setShowGrouping(numberShowGrouping.isSelected()); graphPanel.setValueOrientation(valueLabelsVertical.isSelected()); graphPanel.setLegendPlacement( StatGraphProperties.getPlacementNameMap().get(legendPlacementList.getSelectedItem()).intValue()); graphPanel.setTitleFont( new Font(StatGraphProperties.getFontNameMap().get(titleFontNameList.getSelectedItem()), StatGraphProperties.getFontStyleMap().get(titleFontStyleList.getSelectedItem()).intValue(), Integer.parseInt((String) titleFontSizeList.getSelectedItem()))); graphPanel.setLegendFont(new Font(StatGraphProperties.getFontNameMap().get(fontNameList.getSelectedItem()), StatGraphProperties.getFontStyleMap().get(fontStyleList.getSelectedItem()).intValue(), Integer.parseInt((String) fontSizeList.getSelectedItem()))); graphPanel.setValueFont( new Font(StatGraphProperties.getFontNameMap().get(valueFontNameList.getSelectedItem()), StatGraphProperties.getFontStyleMap().get(valueFontStyleList.getSelectedItem()).intValue(), Integer.parseInt((String) valueFontSizeList.getSelectedItem()))); graphPanel.setHeight(height); graphPanel.setWidth(width); spane.repaint(); }