List of usage examples for java.awt Dimension setSize
public void setSize(int width, int height)
From source file:MyButtonUI.java
public Dimension getPreferredSize(JComponent c) { Dimension d = super.getPreferredSize(c); if (m_borderRaised != null) { Insets ins = m_borderRaised.getBorderInsets(c); d.setSize(d.width + ins.left + ins.right, d.height + ins.top + ins.bottom); }// w w w. j a va2 s. com return d; }
From source file:org.sonar.ide.ui.ModulePanel.java
public ModulePanel(MetadataClient metadataClient) { this.metadataClient = metadataClient; groupId = new JComboBox<String>(); groupId.setEditable(true);/* w ww . ja v a 2s. com*/ groupId.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupChanged(); } }); artifactId = new JComboBox<String>(); artifactId.setEditable(true); artifactId.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { artifactChanged(); } }); branch = new JComboBox<String>(); branch.setEditable(true); branch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { branchChanged(); } }); reloadButton = new JButton("Reload"); //fix minimum width to avoid width jumps between Reload and Loaging... Dimension preferredSize = reloadButton.getPreferredSize(); preferredSize.setSize(90, preferredSize.height); reloadButton.setPreferredSize(preferredSize); reloadButton.setMinimumSize(preferredSize); reloadButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { reload(); } }); DefaultFormBuilder formBuilder = new DefaultFormBuilder(new FormLayout("")); formBuilder.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); formBuilder.appendColumn("right:pref"); formBuilder.appendColumn("3dlu"); formBuilder.appendColumn("fill:p:g"); formBuilder.append("Group ID:", groupId); formBuilder.append("Artifact ID:", artifactId); formBuilder.append("Branch:", branch); add(formBuilder.getPanel()); reload(); }
From source file:com.projity.pm.graphic.chart.TimeChartPanel.java
public void updateTimeScaleComponentSize() { Dimension dmain = viewport.getViewSize(); if (dmain.equals(olddmain)) return;/*from ww w . j a va 2 s . c om*/ olddmain = dmain; Dimension d = chartInfo.getAxisPanel().getPreferredSize(); d.setSize(d.getWidth(), dmain.getHeight()); chartInfo.getAxisPanel().revalidate(); }
From source file:cz.cuni.mff.ksi.jinfer.autoeditor.automatonvisualizer.layouts.vyhnanovska.AutomatonLayoutTransformer.java
private Dimension computeGridDimension(final int minGridSize) { final Dimension dimension = new Dimension(); if (minGridSize < (minXsize * minYsize)) { dimension.setSize(minXsize, minXsize); } else {/*from w w w . j av a 2s .c o m*/ dimension.width = (int) Math.round(Math.sqrt(minGridSize * minYsize / minXsize)); dimension.height = (int) Math.floor(minGridSize / dimension.width) + 1; } return dimension; }
From source file:KjellDirdalNotepad.java
public void setNormalSize() { JScrollPane scrollPane = getScrollPane(); int x = 0;/*from w w w. ja v a 2s . c o m*/ int y = 0; Insets scrollInsets = getScrollPaneInsets(); if (scrollPane != null) { Dimension d = scrollPane.getVisibleRect().getSize(); if (scrollPane.getBorder() != null) { d.setSize(d.getWidth() - scrollInsets.left - scrollInsets.right, d.getHeight() - scrollInsets.top - scrollInsets.bottom); } d.setSize(d.getWidth() - 20, d.getHeight() - 20); desktop.setAllSize(x, y); scrollPane.invalidate(); scrollPane.validate(); } }
From source file:eu.esdihumboldt.hale.io.html.HtmlMappingExporter.java
private Dimension computeSize(Graph graph) { @SuppressWarnings("unchecked") List<GraphNode> graphNodes = graph.getNodes(); int height = 0; int width = 0; List<GraphNode> tempSourceList = new ArrayList<GraphNode>(); List<GraphNode> tempTargetList = new ArrayList<GraphNode>(); for (GraphNode node : graphNodes) { int sourceConnections = node.getSourceConnections().size(); int targetConnections = node.getTargetConnections().size(); if (sourceConnections == 0 && targetConnections == 1) { tempSourceList.add(node);/*from w ww . j av a 2 s.c o m*/ } else if (sourceConnections >= 1 && targetConnections >= 1) { width = width + node.getFigure().getBounds().width + 10; height = height + node.getFigure().getBounds().height; } else { tempTargetList.add(node); } } int accuSourceWidth = 0; int accuSourceHeight = 0; int accuHeight = 0; for (GraphNode node : tempSourceList) { Rectangle rec = node.getFigure().getBounds(); int sourceWidth = rec.width; int sourceHeight = rec.height; accuSourceHeight = accuSourceHeight + sourceHeight + 10; if (accuSourceWidth < sourceWidth) { accuSourceWidth = sourceWidth; } if (accuHeight < accuSourceHeight) { accuHeight = accuSourceHeight; } } int accuTargetWidth = 0; int accuTargetHeight = 0; for (GraphNode node : tempTargetList) { Rectangle rec = node.getFigure().getBounds(); int targetWidth = rec.width; int targetHeight = rec.height; accuTargetHeight = accuTargetHeight + targetHeight + 10; if (accuTargetWidth < targetWidth) { accuTargetWidth = targetWidth; } if (accuHeight < accuTargetHeight) { accuHeight = accuTargetHeight; } } width = width + accuSourceWidth + accuTargetWidth + 30; height = accuHeight + 15; Dimension dimension = new Dimension(); dimension.setSize(width, height); return dimension; }
From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.ChartDisplayPanel.java
/** * Creates a Swing control that displays this panel's chart. * <p>//from w w w. j ava 2s. c om * The newly created panel is stored in the {@link #chartPanel} field. * </p> * * @return The newly created panel instance that displays the chart. */ private JPanel createChartPanel() { chartPanel = JFreeChartConn.createPanel(chart); Dimension size = chartPanel.getPreferredSize(); size.setSize(size.getWidth() / 3 * 2, size.getHeight() / 3 * 2); chartPanel.setPreferredSize(size); return chartPanel; }
From source file:KjellDirdalNotepad.java
protected void resizeDesktop() { int x = 0;/* w ww . j av a2s .co m*/ int y = 0; JScrollPane scrollPane = getScrollPane(); Insets scrollInsets = getScrollPaneInsets(); if (scrollPane != null) { JInternalFrame allFrames[] = desktop.getAllFrames(); for (int i = 0; i < allFrames.length; i++) { if (allFrames[i].getX() + allFrames[i].getWidth() > x) { x = allFrames[i].getX() + allFrames[i].getWidth(); } if (allFrames[i].getY() + allFrames[i].getHeight() > y) { y = allFrames[i].getY() + allFrames[i].getHeight(); } } Dimension d = scrollPane.getVisibleRect().getSize(); if (scrollPane.getBorder() != null) { d.setSize(d.getWidth() - scrollInsets.left - scrollInsets.right, d.getHeight() - scrollInsets.top - scrollInsets.bottom); } if (x <= d.getWidth()) x = ((int) d.getWidth()) - 20; if (y <= d.getHeight()) y = ((int) d.getHeight()) - 20; desktop.setAllSize(x, y); scrollPane.invalidate(); scrollPane.validate(); } }
From source file:org.geotools.gce.imagemosaic.ImageMosaicPostgisIndexTest.java
/** * Complex test for Postgis indexing on db. * //w w w . j a va 2 s. co m * @throws Exception */ @SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void testPostgisIndexing() throws Exception { final File workDir = new File(TestData.file(this, "."), "watertemp4"); assertTrue(workDir.mkdir()); FileUtils.copyFile(TestData.file(this, "watertemp.zip"), new File(workDir, "watertemp.zip")); TestData.unzipFile(this, "watertemp4/watertemp.zip"); final URL timeElevURL = TestData.url(this, "watertemp4"); //place datastore.properties file in the dir for the indexing FileWriter out = null; try { out = new FileWriter(new File(TestData.file(this, "."), "/watertemp4/datastore.properties")); final Set<Object> keyset = fixture.keySet(); for (Object key : keyset) { final String key_ = (String) key; final String value = fixture.getProperty(key_); out.write(key_.replace(" ", "\\ ") + "=" + value.replace(" ", "\\ ") + "\n"); } out.flush(); } finally { if (out != null) { IOUtils.closeQuietly(out); } } // now start the test final AbstractGridFormat format = TestUtils.getFormat(timeElevURL); assertNotNull(format); ImageMosaicReader reader = TestUtils.getReader(timeElevURL, format); assertNotNull(reader); final String[] metadataNames = reader.getMetadataNames(); assertNotNull(metadataNames); assertEquals(metadataNames.length, 10); assertEquals("true", reader.getMetadataValue("HAS_TIME_DOMAIN")); final String timeMetadata = reader.getMetadataValue("TIME_DOMAIN"); assertNotNull(timeMetadata); assertEquals(2, timeMetadata.split(",").length); assertEquals(timeMetadata.split(",")[0], reader.getMetadataValue("TIME_DOMAIN_MINIMUM")); assertEquals(timeMetadata.split(",")[1], reader.getMetadataValue("TIME_DOMAIN_MAXIMUM")); assertEquals("true", reader.getMetadataValue("HAS_ELEVATION_DOMAIN")); final String elevationMetadata = reader.getMetadataValue("ELEVATION_DOMAIN"); assertNotNull(elevationMetadata); assertEquals(2, elevationMetadata.split(",").length); assertEquals(Double.parseDouble(elevationMetadata.split(",")[0]), Double.parseDouble(reader.getMetadataValue("ELEVATION_DOMAIN_MINIMUM")), 1E-6); assertEquals(Double.parseDouble(elevationMetadata.split(",")[1]), Double.parseDouble(reader.getMetadataValue("ELEVATION_DOMAIN_MAXIMUM")), 1E-6); // limit yourself to reading just a bit of it final ParameterValue<GridGeometry2D> gg = AbstractGridFormat.READ_GRIDGEOMETRY2D.createValue(); final GeneralEnvelope envelope = reader.getOriginalEnvelope(); final Dimension dim = new Dimension(); dim.setSize(reader.getOriginalGridRange().getSpan(0) / 2.0, reader.getOriginalGridRange().getSpan(1) / 2.0); final Rectangle rasterArea = ((GridEnvelope2D) reader.getOriginalGridRange()); rasterArea.setSize(dim); final GridEnvelope2D range = new GridEnvelope2D(rasterArea); gg.setValue(new GridGeometry2D(range, envelope)); // use imageio with defined tiles final ParameterValue<List> time = ImageMosaicFormat.TIME.createValue(); final List<Date> timeValues = new ArrayList<Date>(); final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.sss'Z'"); sdf.setTimeZone(TimeZone.getTimeZone("GMT+0")); Date date = sdf.parse("2008-10-31T00:00:00.000Z"); timeValues.add(date); time.setValue(timeValues); final ParameterValue<double[]> bkg = ImageMosaicFormat.BACKGROUND_VALUES.createValue(); bkg.setValue(new double[] { -9999.0 }); final ParameterValue<Boolean> direct = ImageMosaicFormat.USE_JAI_IMAGEREAD.createValue(); direct.setValue(false); final ParameterValue<List> elevation = ImageMosaicFormat.ELEVATION.createValue(); elevation.setValue(Arrays.asList(100.0)); // Test the output coverage TestUtils.checkCoverage(reader, new GeneralParameterValue[] { gg, time, bkg, elevation, direct }, "Time-Elevation Test"); reader = TestUtils.getReader(timeElevURL, format); // Test the output coverage elevation.setValue(Arrays.asList(NumberRange.create(0.0, 10.0))); TestUtils.checkCoverage(reader, new GeneralParameterValue[] { gg, time, bkg, elevation, direct }, "Time-Elevation Test"); reader.dispose(); }
From source file:org.geotools.gce.imagemosaic.ImageMosaicPostgisIndexOnlineTest.java
/** * Complex test for Postgis indexing on db. * //w w w . j av a2 s. c om * @throws Exception */ @SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void testPostgisIndexing() throws Exception { final File workDir = new File(TestData.file(this, "."), tempFolderName1); assertTrue(workDir.mkdir()); FileUtils.copyFile(TestData.file(this, "watertemp.zip"), new File(workDir, "watertemp.zip")); TestData.unzipFile(this, tempFolderName1 + "/watertemp.zip"); final URL timeElevURL = TestData.url(this, tempFolderName1); //place datastore.properties file in the dir for the indexing FileWriter out = null; try { out = new FileWriter(new File(TestData.file(this, "."), tempFolderName1 + "/datastore.properties")); final Set<Object> keyset = fixture.keySet(); for (Object key : keyset) { final String key_ = (String) key; final String value = fixture.getProperty(key_); out.write(key_.replace(" ", "\\ ") + "=" + value.replace(" ", "\\ ") + "\n"); } out.flush(); } finally { if (out != null) { IOUtils.closeQuietly(out); } } // now start the test final AbstractGridFormat format = TestUtils.getFormat(timeElevURL); assertNotNull(format); ImageMosaicReader reader = TestUtils.getReader(timeElevURL, format); assertNotNull(reader); final String[] metadataNames = reader.getMetadataNames(); assertNotNull(metadataNames); assertEquals(12, metadataNames.length); assertEquals("true", reader.getMetadataValue("HAS_TIME_DOMAIN")); final String timeMetadata = reader.getMetadataValue("TIME_DOMAIN"); assertNotNull(timeMetadata); assertEquals(2, timeMetadata.split(",").length); assertEquals(timeMetadata.split(",")[0], reader.getMetadataValue("TIME_DOMAIN_MINIMUM")); assertEquals(timeMetadata.split(",")[1], reader.getMetadataValue("TIME_DOMAIN_MAXIMUM")); assertEquals("true", reader.getMetadataValue("HAS_ELEVATION_DOMAIN")); final String elevationMetadata = reader.getMetadataValue("ELEVATION_DOMAIN"); assertNotNull(elevationMetadata); assertEquals(2, elevationMetadata.split(",").length); assertEquals(Double.parseDouble(elevationMetadata.split(",")[0]), Double.parseDouble(reader.getMetadataValue("ELEVATION_DOMAIN_MINIMUM")), 1E-6); assertEquals(Double.parseDouble(elevationMetadata.split(",")[1]), Double.parseDouble(reader.getMetadataValue("ELEVATION_DOMAIN_MAXIMUM")), 1E-6); // limit yourself to reading just a bit of it final ParameterValue<GridGeometry2D> gg = AbstractGridFormat.READ_GRIDGEOMETRY2D.createValue(); final GeneralEnvelope envelope = reader.getOriginalEnvelope(); final Dimension dim = new Dimension(); dim.setSize(reader.getOriginalGridRange().getSpan(0) / 2.0, reader.getOriginalGridRange().getSpan(1) / 2.0); final Rectangle rasterArea = ((GridEnvelope2D) reader.getOriginalGridRange()); rasterArea.setSize(dim); final GridEnvelope2D range = new GridEnvelope2D(rasterArea); gg.setValue(new GridGeometry2D(range, envelope)); // use imageio with defined tiles final ParameterValue<List> time = ImageMosaicFormat.TIME.createValue(); final List<Date> timeValues = new ArrayList<Date>(); final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.sss'Z'"); sdf.setTimeZone(TimeZone.getTimeZone("GMT+0")); Date date = sdf.parse("2008-10-31T00:00:00.000Z"); timeValues.add(date); time.setValue(timeValues); final ParameterValue<double[]> bkg = ImageMosaicFormat.BACKGROUND_VALUES.createValue(); bkg.setValue(new double[] { -9999.0 }); final ParameterValue<Boolean> direct = ImageMosaicFormat.USE_JAI_IMAGEREAD.createValue(); direct.setValue(false); final ParameterValue<List> elevation = ImageMosaicFormat.ELEVATION.createValue(); elevation.setValue(Arrays.asList(100.0)); // Test the output coverage assertNotNull(reader.read(new GeneralParameterValue[] { gg, time, bkg, elevation, direct })); TestUtils.checkCoverage(reader, new GeneralParameterValue[] { gg, time, bkg, elevation, direct }, "Time-Elevation Test"); // Test the output coverage reader = TestUtils.getReader(timeElevURL, format); elevation.setValue(Arrays.asList(NumberRange.create(0.0, 10.0))); TestUtils.checkCoverage(reader, new GeneralParameterValue[] { gg, time, bkg, elevation, direct }, "Time-Elevation Test"); }