Java Code Examples for java.awt.Rectangle
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
From project addis, under directory /application/src/main/java/org/drugis/addis/gui/components/.
Source file: JTableWithPopupEditor.java

private void setWindowLocation(){ Rectangle cellLocation=getCellRect(d_row,d_col,false); Point l=getComponentAt(d_col,d_row).getLocationOnScreen(); l.translate(cellLocation.x + cellLocation.width / 2,cellLocation.y + cellLocation.height / 2); d_window.setLocation(l); }
Example 2
From project Agot-Java, under directory /src/main/java/got/ui/update/.
Source file: ImageScrollerSmallView.java

@Override public void mouseDragged(final MouseEvent e){ final long now=System.currentTimeMillis(); if (now < mLastUpdate + MIN_UPDATE_DELAY) return; mLastUpdate=now; final Rectangle bounds=(Rectangle)getBounds().clone(); bounds.grow(0,0); if (!bounds.contains(e.getPoint())) return; final int x=(int)(e.getX() / getRatioX()) - (m_model.getBoxWidth() / 2); final int y=(int)(e.getY() / getRatioY()) - (m_model.getBoxHeight() / 2); if (x <= m_model.getMaxWidth() - m_model.getBoxWidth() && y <= m_model.getMaxHeight() - m_model.getBoxHeight()) { setSelection(x,y); } }
Example 3
From project Aion-Extreme, under directory /AE-go_GameServer/src/com/aionemu/gameserver/model/geometry/.
Source file: RectangleArea.java

/** * Creates new area from given points. Point order doesn't matter * @param p1 point * @param p2 point * @param p3 point * @param p4 point * @param minZ minimal z * @param maxZ maximal z */ public RectangleArea(Point p1,Point p2,Point p3,Point p4,int minZ,int maxZ){ super(minZ,maxZ); Rectangle r=new Rectangle(); r.add(p1); r.add(p2); r.add(p3); r.add(p4); minX=(int)r.getMinX(); maxX=(int)r.getMaxX(); minY=(int)r.getMinY(); maxY=(int)r.getMaxY(); }
Example 4
/** * Gets the column number at given position of editor. The first column is ZERO * @param editor * @param pos * @return the 0 based column number * @throws javax.swing.text.BadLocationException */ public static int getColumnNumber(JTextComponent editor,int pos) throws BadLocationException { if (pos == 0) { return 0; } Rectangle r=editor.modelToView(pos); int start=editor.viewToModel(new Point(0,r.y)); int column=pos - start; return column; }
Example 5
From project ceres, under directory /ceres-glayer/src/main/java/com/bc/ceres/glayer/support/.
Source file: BackgroundLayer.java

@Override protected void renderLayer(Rendering rendering){ final Graphics2D g=rendering.getGraphics(); Paint oldPaint=g.getPaint(); g.setPaint(getColor()); Rectangle bounds=g.getClipBounds(); g.fillRect(bounds.x,bounds.y,bounds.width,bounds.height); g.setPaint(oldPaint); }
Example 6
public void paintIcon(Component c,Graphics g,int x,int y){ Rectangle r=new Rectangle(x,y,WIDTH - 1,HEIGHT - 1); Graphics2D g2=(Graphics2D)g; Color oldColor=g2.getColor(); g2.setColor(color); g2.fill(r); g2.setColor(Color.BLACK); g2.draw(r); g2.setColor(oldColor); }
Example 7
From project Clotho-Core, under directory /ClothoApps/PluginManager/src/org/clothocore/tool/pluginmanager/gui/.
Source file: ChoosePreferredViewers.java

private DrawableAvatar getHitAvatar(int x,int y){ for ( DrawableAvatar avatar : drawableAvatars) { Rectangle hit=new Rectangle((int)avatar.getX(),(int)avatar.getY(),avatar.getWidth(),avatar.getHeight() / 2); if (hit.contains(x,y)) { return avatar; } } return null; }
Example 8
From project cowgraph, under directory /CowGraph/CowGraphVisualEditor/src/zbeans/cowgraph/visual/editor/widget/.
Source file: ArrowWidget.java

@Override protected Rectangle calculateClientArea(){ Rectangle rect=new Rectangle(); rect.add(element.getX(),element.getY()); rect.add(element.getToX(),element.getToY()); return rect; }
Example 9
From project dawn-common, under directory /org.dawb.hdf5/src/ncsa/hdf/view/.
Source file: DefaultImageView.java

public void setDimensions(int width,int height){ Rectangle rect=new Rectangle(0,0,width,height); transformBBox(rect); xoffset=-rect.x; yoffset=-rect.y; srcW=width; srcH=height; dstW=rect.width; dstH=rect.height; raster=new int[srcW * srcH]; consumer.setDimensions(dstW,dstH); }
Example 10
From project en4j, under directory /NBPlatformApp/MainModule/src/main/java/com/rubenlaguna/en4j/mainmodule/.
Source file: CustomGlassPane.java

@Override protected void paintComponent(Graphics g){ Rectangle clip=g.getClipBounds(); Graphics2D g2=(Graphics2D)g.create(); AlphaComposite alpha=AlphaComposite.SrcOver.derive(0.65f); g2.setComposite(alpha); g2.setColor(getBackground()); g2.fillRect(clip.x,clip.y,clip.width,clip.height); }
Example 11
From project encog-java-workbench, under directory /src/main/java/org/encog/workbench/tabs/visualize/scatter/.
Source file: LegendPanel.java

public void paint(Graphics g){ Graphics2D g2d=(Graphics2D)g; BlockParams p=new BlockParams(); p.setGenerateEntities(true); Rectangle area=new Rectangle(0,0,this.getWidth(),this.getHeight()); legend.arrange(g2d); legend.draw(g2d,area,p); }
Example 12
From project fastjson, under directory /src/test/java/com/alibaba/json/bvt/.
Source file: RectangleTest.java

public void test_color() throws Exception { JSONSerializer serializer=new JSONSerializer(); Assert.assertEquals(RectangleSerializer.class,serializer.getObjectWriter(Rectangle.class).getClass()); Rectangle v=new Rectangle(3,4,100,200); String text=JSON.toJSONString(v,SerializerFeature.WriteClassName); System.out.println(text); Rectangle v2=(Rectangle)JSON.parse(text); Assert.assertEquals(v,v2); }
Example 13
From project fest-assert-2.x, under directory /src/test/java/org/fest/assertions/internal/.
Source file: StandardComparisonStrategy_isGreaterThanOrEqualTo_Test.java

@Test public void should_fail_if_a_parameter_is_not_comparable(){ thrown.expect(IllegalArgumentException.class); Rectangle r1=new Rectangle(10,20); Rectangle r2=new Rectangle(20,10); standardComparisonStrategy.isGreaterThanOrEqualTo(r1,r2); }
Example 14
From project flyingsaucer, under directory /flying-saucer-core/src/main/java/org/xhtmlrenderer/layout/.
Source file: BoxCollector.java

private boolean intersectsAggregateBounds(Shape clip,Box box){ if (clip == null) { return true; } PaintingInfo info=box.getPaintingInfo(); if (info == null) { return false; } Rectangle bounds=info.getAggregateBounds(); return clip.intersects(bounds); }
Example 15
From project alg-vis, under directory /src/algvis/internationalization/.
Source file: ChButton.java

void refresh(){ FontMetrics metrics=getFontMetrics(getFont()); int width=metrics.stringWidth(getText()); int height=metrics.getHeight(); Dimension newDimension=new Dimension(width + 40,height + 10); setPreferredSize(newDimension); setBounds(new Rectangle(getLocation(),getPreferredSize())); }
Example 16
From project autopsy, under directory /Testing/test/qa-functional/src/org/sleuthkit/autopsy/testing/.
Source file: RegressionTest.java

public void screenshot(String name){ logger.info("Taking screenshot."); try { Rectangle screenRect=new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()); BufferedImage capture=new Robot().createScreenCapture(screenRect); String outPath=System.getProperty("out_path"); ImageIO.write(capture,"png",new File(outPath + "\\" + name+ ".png")); new Timeout("pausing",1000).sleep(); } catch ( IOException ex) { logger.info("IOException taking screenshot."); } catch ( AWTException ex) { logger.info("AWTException taking screenshot."); } }
Example 17
From project beam-meris-icol, under directory /src/main/java/org/esa/beam/meris/icol/common/.
Source file: AdjacencyEffectMaskOp.java

private Area computeCoastalArea(ProgressMonitor pm,Rectangle sourceRect,Tile land,Tile coastline){ Rectangle box=new Rectangle(); Area coastalArea=new Area(); for (int y=sourceRect.y; y < sourceRect.y + sourceRect.height; y++) { for (int x=sourceRect.x; x < sourceRect.x + sourceRect.width; x++) { if (isCoastline(land,coastline,x,y)) { box.setBounds(x - aeWidth,y - aeWidth,2 * aeWidth,2 * aeWidth); Area area2=new Area(box); coastalArea.add(area2); } } pm.worked(1); } return coastalArea; }
Example 18
From project beam-third-party, under directory /mssl-stereomatcher/src/main/java/uk/ac/ucl/mssl/climatephysics/beam/atsr/.
Source file: ExpectedDisparities.java

@Override public void computeTile(Band targetBand,Tile targetTile,ProgressMonitor pm) throws OperatorException { Rectangle targetRect=targetTile.getRectangle(); pm.beginTask("Computing filter",targetRect.height + 4); try { Tile elevationTile=getSourceTile(elevationTiePointGrid,targetRect); for (int y=targetRect.y; y < targetRect.y + targetRect.height; y++) { for (int x=targetRect.x; x < targetRect.x + targetRect.width; x++) { final double elevation=elevationTile.getSampleDouble(x,y); targetTile.setSample(x,y,Math.max(Math.round(elevation / disparityStep),0)); } if (pm.isCanceled()) { return; } pm.worked(1); } } finally { pm.done(); } }
Example 19
/** * Get the calibrated 3D coordinates of point ROIs from the ROI manager * @param imp * @param roiMan * @return double[n][3] containing n (x, y, z) coordinates */ public static double[][] getRoiManPoints(ImagePlus imp,RoiManager roiMan){ Calibration cal=imp.getCalibration(); double vW=cal.pixelWidth; double vH=cal.pixelHeight; double vD=cal.pixelDepth; int nPoints=0; List listRoi=roiMan.getList(); Roi[] roiList=roiMan.getRoisAsArray(); for (int i=0; i < roiMan.getCount(); i++) { Roi roi=roiList[i]; if (roi.getType() == 10) { nPoints++; } } double[][] dataPoints=new double[nPoints][3]; int j=0; for (int i=0; i < roiMan.getCount(); i++) { Roi roi=roiList[i]; if (roi.getType() == 10) { String label=listRoi.getItem(i); Rectangle xy=roi.getBounds(); dataPoints[j][0]=xy.getX() * vW; dataPoints[j][1]=xy.getY() * vH; dataPoints[j][2]=roiMan.getSliceNumber(label) * vD; j++; } } return dataPoints; }
Example 20
From project des, under directory /daemon/lib/apache-log4j-1.2.16/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/.
Source file: CategoryImmediateEditor.java

public boolean inCheckBoxHitRegion(MouseEvent e){ TreePath path=tree.getPathForLocation(e.getX(),e.getY()); if (path == null) { return false; } CategoryNode node=(CategoryNode)path.getLastPathComponent(); boolean rv=false; if (true) { Rectangle bounds=tree.getRowBounds(lastRow); Dimension checkBoxOffset=renderer.getCheckBoxOffset(); bounds.translate(offset + checkBoxOffset.width,checkBoxOffset.height); rv=bounds.contains(e.getPoint()); } return true; }
Example 21
From project dolphin, under directory /dolphinmaple/src/com/tan/util/.
Source file: ScreenCapture.java

public static String createScreenCapture(){ OutputStream os=null; String path=ScreenCapture.class.getResource("/").getFile(); try { Robot robot=new Robot(); Rectangle rect=new Rectangle(0,0,1028,1024); BufferedImage bimg=robot.createScreenCapture(rect); os=new FileOutputStream(new StringBuilder().append(path.substring(0,path.lastIndexOf("WEB-INF"))).append("Picture").append(File.separator).append("tmp.jpg").toString()); JPEGImageEncoder jer=JPEGCodec.createJPEGEncoder(os); jer.encode(bimg); } catch ( Exception e) { return e.getMessage(); } finally { if (os != null) { try { os.close(); } catch ( IOException e) { e.printStackTrace(); } } } return "successful!!"; }
Example 22
From project drugis-common, under directory /common-gui/src/main/java/org/drugis/common/gui/table/.
Source file: EnhancedTableHeader.java

private TableColumn getResizingColumn(Point p,int column){ if (column == -1) { return null; } Rectangle r=getHeaderRect(column); r.grow(-3,0); if (r.contains(p)) { return null; } int midPoint=r.x + (r.width / 2); int columnIndex; if (getComponentOrientation().isLeftToRight()) { columnIndex=(p.x < midPoint) ? (column - 1) : column; } else { columnIndex=(p.x < midPoint) ? column : (column - 1); } if (columnIndex == -1) { return null; } return getColumnModel().getColumn(columnIndex); }
Example 23
From project extension_libero_manufacturing, under directory /extension/eevolution/libero/src/main/java/it/cnr/imaa/essi/lablib/gui/checkboxtree/.
Source file: CheckboxTree.java

@Override public void mousePressed(MouseEvent e){ int x=e.getX(); int y=e.getY(); int row=getRowForLocation(x,y); if (row == -1) { return; } Rectangle rect=getRowBounds(row); if (rect == null) { return; } if (((CheckboxTreeCellRenderer)getCellRenderer()).isOnHotspot(x - rect.x,y - rect.y)) { getCheckingModel().toggleCheckingPath(getPathForRow(row)); } }
Example 24
From project codjo-data-process, under directory /codjo-data-process-gui/src/main/java/net/codjo/dataprocess/gui/util/.
Source file: GuiUtils.java

public static void setBackgroundColor(MutableGuiContext ctxt,boolean showEnvironment,Color bgDev,Color bgRecette,Color bgProd,int size){ GuiUtils.removeWallPaper(ctxt); String userEnvironment=System.getProperty("user.environment"); JLabel label=new JLabel("D?eloppement",JLabel.CENTER); label.setBounds(new Rectangle(365,219,550,412)); label.setName("WALLPAPER"); label.setFont(label.getFont().deriveFont(Font.BOLD,size)); if (userEnvironment != null && userEnvironment.startsWith("Production")) { label.setText("Production"); ctxt.getDesktopPane().setBackground(bgProd); } else if (userEnvironment != null && userEnvironment.startsWith("Recette")) { label.setText("Recette"); ctxt.getDesktopPane().setBackground(bgRecette); } else { ctxt.getDesktopPane().setBackground(bgDev); } if (showEnvironment) { ctxt.getDesktopPane().add(label); } }
Example 25
From project Core_2, under directory /src/main/java/ch/swingfx/awt/.
Source file: GraphicsEnvironmentUtil.java

/** * Get the x11 net workarea from a call to<br /> <code>xprop -root -notype _NET_WORKAREA</code><br /> On some systems (jvms) we can not get the real screen insets so we read _NET_WORKAREA from the command line.<br /> The output is translated to an Rectangle Output: _NET_WORKAREA = 0, 0, 1680, 1025 Rectangle: x, y, width, height * @return the x11 net workarea or null if we can't read it */ public static Rectangle getX11RootNetWorkarea(){ final ProcessBuilder pc=new ProcessBuilder("xprop","-root","-notype","_NET_WORKAREA"); try { final Process process=pc.start(); final InputStream inputStream=process.getInputStream(); final InputStreamReader inputStreamReader=new InputStreamReader(inputStream); final BufferedReader reader=new BufferedReader(inputStreamReader); String line=reader.readLine(); process.waitFor(); reader.close(); final String[] windowProperties=line.split("=")[1].trim().split(","); final int x=Integer.parseInt(windowProperties[0].trim()); final int y=Integer.parseInt(windowProperties[1].trim()); final int width=Integer.parseInt(windowProperties[2].trim()); final int height=Integer.parseInt(windowProperties[3].trim()); return new Rectangle(x,y,width,height); } catch ( Exception e) { return null; } }
Example 26
From project Briss, under directory /src/main/java/at/laborg/briss/gui/.
Source file: MergedPanel.java

private void updateClusterRatios(List<DrawableCropRect> tmpCrops){ cluster.clearRatios(); for ( Rectangle crop : tmpCrops) { cluster.addRatios(getCutRatiosForPdf(crop,img.getWidth(),img.getHeight())); } }
Example 27
From project brix-cms-plugins, under directory /brix-plugin-file/src/main/java/brix/plugin/file/util/.
Source file: ImageMagicProcessor.java

public static InputStream createCrop(InputStream in,Rectangle rectangle){ IMOperation op=new IMOperation(); op.addImage("-"); op.crop(rectangle.height,rectangle.width,rectangle.x,rectangle.y); op.addImage("-"); Pipe pipeIn=new Pipe(in,null); ByteArrayOutputStream out=new ByteArrayOutputStream(); Pipe pipeOut=new Pipe(null,out); ConvertCmd convert=new ConvertCmd(); convert.setInputProvider(pipeIn); convert.setOutputConsumer(pipeOut); try { convert.run(op); logger.info("createCrop() :{}",convert.toString()); } catch ( Exception e) { e.printStackTrace(); } return new ByteArrayInputStream(out.toByteArray()); }