List of usage examples for java.awt Rectangle getY
public double getY()
From source file:com.projity.pm.graphic.gantt.GanttRenderer.java
public void paint(Graphics g, Rectangle visibleBounds) { Graphics2D g2 = (Graphics2D) g; //CoordinatesConverter coord=((GanttParams)graphInfo).getCoord(); Rectangle clipBounds = g2.getClipBounds(); Rectangle svgClip = clipBounds; if (clipBounds == null) { clipBounds = ((GanttParams) getGraphInfo()).getGanttBounds(); //start at O,O because it's already translated if (visibleBounds == null) clipBounds = new Rectangle(0, 1, clipBounds.width, clipBounds.height - 2);//1 pixel offset needed for edge // else clipBounds=new Rectangle(visibleBounds.x-clipBounds.x,visibleBounds.y-clipBounds.y,visibleBounds.width,visibleBounds.height); else {/*w w w . j a v a2 s .com*/ clipBounds = visibleBounds; g2.setClip(clipBounds); } } paintNonWorkingDays(g2, clipBounds); //Modif for offline graphics double rowHeight = ((GanttParams) graphInfo).getRowHeight(); int i0 = (int) Math.floor(clipBounds.getY() / rowHeight); int i1; if (visibleBounds == null) i1 = (int) Math.ceil(clipBounds.getMaxY() / rowHeight); else i1 = (int) Math.floor(clipBounds.getMaxY() / rowHeight); //double t0=coord.toTime(clipBounds.getX()); //double t1=coord.toTime(clipBounds.getMaxX()); nodeList.clear(); GraphicNode node; // for (ListIterator i=graph.getModel().getNodeIterator(i0);i.hasNext()&&i.nextIndex()<=i1;){ // node=(GraphicNode)i.next(); // if (!node.isSchedule()) continue; // nodeList.add(node); // node.setRow(i.previousIndex()); // paintNode(g2,node,true); // } //Because row not initialized for some nodes NodeModelCache cache = graphInfo.getCache(); for (ListIterator i = cache.getIterator(); i.hasNext();) { node = (GraphicNode) i.next(); node.setRow(i.previousIndex()); if (i.previousIndex() >= i0 && i.previousIndex() < i1) { if (!node.isSchedule()) continue; nodeList.add(node); paintAnnotation(g2, node); paintNode(g2, node, true); paintHorizontalLine(g2, node); } } GraphicDependency dependency; for (Iterator i = cache.getEdgesIterator(); i.hasNext();) { dependency = (GraphicDependency) i.next(); //if (nodeList.contains(dependency.getPredecessor())||nodeList.contains(dependency.getSuccessor())) paintLink(g2, dependency); } for (ListIterator i = nodeList.listIterator(); i.hasNext();) { node = (GraphicNode) i.next(); paintNode(g2, node, false); } if (visibleBounds != null) g2.setClip(svgClip); }
From source file:com.t3.macro.api.views.TokenView.java
/** * Returns a set of the parts of a token that can be seen by this token. * @param target the token of which we want to check what this token can see * @return the set of visible token parts *///from w ww .j a va 2 s.c o m public EnumSet<TokenPart> getVisibleTokenParts(TokenView target) { if (!token.getHasSight()) return EnumSet.noneOf(TokenPart.class); ZoneRenderer zr = TabletopTool.getFrame().getZoneRenderer(token.getZone()); Zone zone = zr.getZone(); Area tokensVisibleArea = zr.getZoneView().getVisibleArea(token); if (tokensVisibleArea == null) return EnumSet.noneOf(TokenPart.class); if (target == null) throw new NullPointerException(); if (!target.isVisible() || (target.token.isVisibleOnlyToOwner() && !AppUtil.playerOwns(target.token))) { return EnumSet.noneOf(TokenPart.class); } Grid grid = zone.getGrid(); Rectangle bounds = target.token.getFootprint(grid).getBounds(grid, grid.convert(new ZonePoint(target.token.getX(), target.token.getY()))); if (!target.token.isSnapToGrid()) bounds = target.token.getBounds(zone); EnumSet<TokenPart> ret = EnumSet.noneOf(TokenPart.class); int x = (int) bounds.getX(); int y = (int) bounds.getY(); int w = (int) bounds.getWidth(); int h = (int) bounds.getHeight(); int halfX = x + (w) / 2; int halfY = y + (h) / 2; if (tokensVisibleArea.intersects(bounds)) { if (tokensVisibleArea.contains(new Point(x, y))) ret.add(TokenPart.TOP_LEFT); if (tokensVisibleArea.contains(new Point(x, y + h))) if (tokensVisibleArea.contains(new Point(x + w, y))) ret.add(TokenPart.TOP_RIGHT); if (tokensVisibleArea.contains(new Point(x + w, y + h))) ret.add(TokenPart.BOTTOM_LEFT); if (tokensVisibleArea.contains(new Point(halfX, halfY))) ret.add(TokenPart.BOTTOM_RIGHT); } return ret; }
From source file:knop.psfj.BeadImage.java
/** * Gets the enlarged frame.//from w w w . ja va 2s .co m * * @param r the r * @return the enlarged frame */ public Rectangle getEnlargedFrame(Rectangle r) { Rectangle rn = new Rectangle(); int f = frameSize; if (frameSize * frameSize >= imageWidth * imageHeight * 0.8) { rn.setLocation(0, 0); rn.setSize(imageWidth, imageHeight); return rn; } int x = MathUtils.round(r.getX() + r.getWidth() / 2 - f / 2); int y = MathUtils.round(r.getY() + r.getHeight() / 2 - f / 2); x -= 1; y -= 1; int w = f; int h = f; rn.setLocation(x, y); rn.setSize(w, h); return rn; }
From source file:net.sqs2.omr.session.logic.PageImageRenderer.java
private static void drawFormAreas(int pageIndex, float densityThreshold, FormMaster master, PageTaskResult pageTaskResult, Graphics2D g, MarkRecognitionConfig markRecognizationConfig, DeskewedImageSource pageSource, int focusedColumnIndex, Rectangle scope) { int formAreaIndexInPage = 0; int minX = Integer.MAX_VALUE; int minY = Integer.MAX_VALUE; int maxX = Integer.MIN_VALUE; int maxY = Integer.MIN_VALUE; for (FormArea formArea : master.getFormAreaListByPageIndex(pageIndex)) { FormAreaResult result = (FormAreaResult) pageTaskResult.getPageAreaResultList() .get(formAreaIndexInPage); if (formArea.isMarkArea()) { if (focusedColumnIndex == formArea.getQuestionIndex()) { Rectangle rect = formArea.getRect(); Point2D p1 = pageSource.getPoint((int) rect.getX(), (int) rect.getY()); Point2D p2 = pageSource.getPoint((int) (rect.getX() + rect.getWidth()), (int) (rect.getY() + rect.getHeight())); minX = Math.min(minX, (int) p1.getX()); minY = Math.min(minY, (int) p1.getY()); maxX = Math.max(maxX, (int) p2.getX()); maxY = Math.max(maxY, (int) p2.getY()); if (result.getDensity() < densityThreshold) { g.setColor(FOCUSED_MARKED_COLOR); } else { g.setColor(FOCUSED_NO_MARKED_COLOR); }// ww w . j a va2 s . c o m } else { if (result.getDensity() < densityThreshold) { g.setColor(MARKED_COLOR); } else { g.setColor(NO_MARKED_COLOR); } } g.fillPolygon(pageSource.createRectPolygon( getExtendedRectangle(formArea.getRect(), markRecognizationConfig.getHorizontalMargin(), markRecognizationConfig.getVerticalMargin()))); g.drawPolygon(pageSource.createRectPolygon( getExtendedRectangle(formArea.getRect(), markRecognizationConfig.getHorizontalMargin() + 3, markRecognizationConfig.getVerticalMargin() + 3))); } else { g.setColor(TEXTAREA_COLOR); g.fillPolygon(pageSource.createRectPolygon(formArea.getRect())); } formAreaIndexInPage++; } if (scope != null) { int borderMarginX = 20; int borderMarginY = 3; int margin = 40; int x = minX - borderMarginX; int y = minY - borderMarginY; int width = maxX - minX + borderMarginX * 2; int height = maxY - minY + borderMarginY * 2; scope.x = minX - margin; scope.y = minY - margin; scope.width = maxX - minX + margin * 2; scope.height = maxY - minY + margin * 2; Stroke stroke = new BasicStroke(4.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 2.0f, new float[] { 4.0f, 8.0f }, 0.0f); g.setStroke(stroke); g.setColor(FOCUSED_SCOPE_COLOR); g.drawRoundRect(x, y, width, height, 20, 20); } }
From source file:org.apache.cayenne.swing.components.textpane.JCayenneTextPane.java
/** * Return an int containing the wrapped line index at the given position * /* w w w. ja v a2 s . com*/ * @param int pos * @return int */ public int getLineNumber(int pos) { int posLine; int y = 0; try { Rectangle caretCoords = pane.modelToView(pos); y = (int) caretCoords.getY(); } catch (BadLocationException ex) { logObj.warn("Error: ", ex); } int lineHeight = pane.getFontMetrics(pane.getFont()).getHeight(); posLine = (y / lineHeight) + 1; return posLine; }
From source file:org.apache.fop.render.pdf.pdfbox.PDFBoxImageHandler.java
public void handleImage(RenderingContext context, Image image, Rectangle pos) throws IOException { assert context instanceof PDFRenderingContext; PDFRenderingContext pdfContext = (PDFRenderingContext) context; PDFContentGenerator generator = pdfContext.getGenerator(); assert image instanceof ImagePDF; ImagePDF pdfImage = (ImagePDF) image; float x = (float) pos.getX() / 1000f; float y = (float) pos.getY() / 1000f; // float w = (float)pos.getWidth() / 1000f; float h = (float) pos.getHeight() / 1000f; AffineTransform pageAdjust = new AffineTransform(); AffineTransform at = generator.getAffineTransform(); if (at != null) { pageAdjust.setToTranslation((float) (generator.getState().getTransform().getTranslateX()), (float) (generator.getState().getTransform().getTranslateY() - h - y)); }/*w ww. j a v a2s.c o m*/ FontInfo fontinfo = (FontInfo) context.getHint("fontinfo"); String stream = createStreamForPDF(pdfImage, pdfContext.getPage(), pdfContext.getUserAgent(), pageAdjust, fontinfo, pos, pdfContext.getPageNumbers(), pdfContext.getPdfLogicalStructureHandler(), pdfContext.getCurrentSessionStructElem()); if (stream == null) { return; } if (pageAdjust.getScaleX() != 0) { pageAdjust.translate(x * (1 / pageAdjust.getScaleX()), -y * (1 / -pageAdjust.getScaleY())); } generator.placeImage(pageAdjust, stream); }
From source file:org.apache.fop.render.ps.PSImageHandlerEPS.java
/** {@inheritDoc} */ public void handleImage(RenderingContext context, Image image, Rectangle pos) throws IOException { PSRenderingContext psContext = (PSRenderingContext) context; PSGenerator gen = psContext.getGenerator(); ImageRawEPS eps = (ImageRawEPS) image; float x = (float) pos.getX() / 1000f; float y = (float) pos.getY() / 1000f; float w = (float) pos.getWidth() / 1000f; float h = (float) pos.getHeight() / 1000f; ImageInfo info = image.getInfo();// w w w. ja v a 2 s . com Rectangle2D bbox = eps.getBoundingBox(); if (bbox == null) { bbox = new Rectangle2D.Double(); bbox.setFrame(new Point2D.Double(), info.getSize().getDimensionPt()); } InputStream in = eps.createInputStream(); try { String resourceName = info.getOriginalURI(); if (resourceName == null) { resourceName = "inline image"; } PSImageUtils.renderEPS(in, resourceName, new Rectangle2D.Float(x, y, w, h), bbox, gen); } finally { IOUtils.closeQuietly(in); } }
From source file:org.executequery.gui.erd.ErdTable.java
public void selected(MouseEvent e) { super.selected(e); Rectangle bounds = getBounds(); Rectangle titleBar = new Rectangle((int) bounds.getX(), (int) bounds.getY(), FINAL_WIDTH, TITLE_BAR_HEIGHT); if (titleBar.contains(xDifference, yDifference)) { dragging = true;/*from w w w . jav a2 s . c o m*/ } else { dragging = false; } // need to repaint layered pane to show // selected border on tables parent.repaintLayeredPane(); }
From source file:org.opencastproject.metadata.mpeg7.Mpeg7Test.java
/** * Tests the contents of the sample catalog mpeg7.xml. *///from w w w . j a v a 2 s . c o m @SuppressWarnings("unchecked") protected void testContent(Mpeg7Catalog mpeg7) { // Check presence of content assertTrue(mpeg7.hasAudioContent()); assertTrue(mpeg7.hasVideoContent()); assertFalse(mpeg7.hasAudioVisualContent()); // Check content size assertTrue(mpeg7.getMultimediaContent(MultimediaContent.Type.AudioType).size() == 1); assertTrue(mpeg7.getMultimediaContent(MultimediaContent.Type.VideoType).size() == 2); // Check tracks assertNotNull(mpeg7.getAudioById("track-1")); assertNotNull(mpeg7.getVideoById("track-2")); assertNotNull(mpeg7.getVideoById("track-3")); // // Check audio track (track-1) // MultimediaContentType track1 = mpeg7.getAudioById("track-1"); MediaTime audioMediaTime = track1.getMediaTime(); // Media locator assertEquals(track1.getMediaLocator().getMediaURI(), URI.create("file:tracks/audio.pcm")); // Media time point assertEquals(0, audioMediaTime.getMediaTimePoint().getDay()); assertEquals(0, audioMediaTime.getMediaTimePoint().getHour()); assertEquals(0, audioMediaTime.getMediaTimePoint().getMinutes()); assertEquals(0, audioMediaTime.getMediaTimePoint().getSeconds()); assertEquals(25, audioMediaTime.getMediaTimePoint().getFractionsPerSecond()); assertEquals(0, audioMediaTime.getMediaTimePoint().getNFractions()); // Media duration assertEquals(0, audioMediaTime.getMediaDuration().getDays()); assertEquals(1, audioMediaTime.getMediaDuration().getHours()); assertEquals(30, audioMediaTime.getMediaDuration().getMinutes()); assertEquals(0, audioMediaTime.getMediaDuration().getSeconds()); // Segments assertFalse(track1.getTemporalDecomposition().segments().hasNext()); // // Check video track (track-2) // MultimediaContentType track2 = mpeg7.getVideoById("track-2"); MediaTime v1MediaTime = track2.getMediaTime(); // Media locator assertEquals(track2.getMediaLocator().getMediaURI(), URI.create("file:tracks/presentation.mp4")); // Media time point assertEquals(0, v1MediaTime.getMediaTimePoint().getDay()); assertEquals(0, v1MediaTime.getMediaTimePoint().getHour()); assertEquals(0, v1MediaTime.getMediaTimePoint().getMinutes()); assertEquals(0, v1MediaTime.getMediaTimePoint().getSeconds()); assertEquals(25, v1MediaTime.getMediaTimePoint().getFractionsPerSecond()); assertEquals(0, v1MediaTime.getMediaTimePoint().getNFractions()); // Media duration assertEquals(0, v1MediaTime.getMediaDuration().getDays()); assertEquals(1, v1MediaTime.getMediaDuration().getHours()); assertEquals(30, v1MediaTime.getMediaDuration().getMinutes()); assertEquals(0, v1MediaTime.getMediaDuration().getSeconds()); // Segments TemporalDecomposition<VideoSegment> v1Decomposition = (TemporalDecomposition<VideoSegment>) track2 .getTemporalDecomposition(); assertFalse(v1Decomposition.hasGap()); assertFalse(v1Decomposition.isOverlapping()); assertEquals(v1Decomposition.getCriteria(), TemporalDecomposition.DecompositionCriteria.Temporal); assertTrue(v1Decomposition.segments().hasNext()); // Segment track-2.segment-1 VideoSegment v1Segment1 = v1Decomposition.getSegmentById("track-2.segment-1"); assertNotNull(v1Segment1); MediaTime segment1MediaTime = v1Segment1.getMediaTime(); // Media time point assertEquals(0, segment1MediaTime.getMediaTimePoint().getDay()); assertEquals(0, segment1MediaTime.getMediaTimePoint().getHour()); assertEquals(0, segment1MediaTime.getMediaTimePoint().getMinutes()); assertEquals(0, segment1MediaTime.getMediaTimePoint().getSeconds()); assertEquals(25, segment1MediaTime.getMediaTimePoint().getFractionsPerSecond()); assertEquals(0, segment1MediaTime.getMediaTimePoint().getNFractions()); // Media duration assertEquals(0, segment1MediaTime.getMediaDuration().getDays()); assertEquals(1, segment1MediaTime.getMediaDuration().getHours()); assertEquals(7, segment1MediaTime.getMediaDuration().getMinutes()); assertEquals(35, segment1MediaTime.getMediaDuration().getSeconds()); // Text annotations assertTrue(v1Segment1.hasTextAnnotations()); assertTrue(v1Segment1.hasTextAnnotations(0.4f, 0.5f)); assertFalse(v1Segment1.hasTextAnnotations(0.8f, 0.8f)); assertTrue(v1Segment1.hasTextAnnotations("de")); assertFalse(v1Segment1.hasTextAnnotations("fr")); // Keywords TextAnnotation textAnnotation = v1Segment1.textAnnotations().next(); assertEquals("Armin", textAnnotation.keywordAnnotations().next().getKeyword()); assertEquals("Hint Armin", textAnnotation.freeTextAnnotations().next().getText()); // Spaciotemporal decomposition SpatioTemporalDecomposition stdecomposition = v1Segment1.getSpatioTemporalDecomposition(); assertNotNull(stdecomposition); assertTrue(stdecomposition.hasGap()); assertFalse(stdecomposition.isOverlapping()); // VideoText assertEquals(1, stdecomposition.getVideoText().length); VideoText videoText = stdecomposition.getVideoText("text1"); assertNotNull(videoText); SpatioTemporalLocator locator = videoText.getSpatioTemporalLocator(); assertNotNull(locator); MediaTime locatorMediaTime = locator.getMediaTime(); assertNotNull(locatorMediaTime); assertEquals(MediaRelTimePointImpl.parseTimePoint("T00:00:00:0F25"), locatorMediaTime.getMediaTimePoint()); assertEquals(MediaDurationImpl.parseDuration("PT01H07M35S"), locatorMediaTime.getMediaDuration()); Textual textual = videoText.getText(); assertNotNull(textual); assertEquals("Text", textual.getText()); assertEquals("en", textual.getLanguage()); Rectangle boundingBox = videoText.getBoundary(); assertNotNull(boundingBox); assertEquals(10, (int) boundingBox.getX()); assertEquals(150, (int) boundingBox.getWidth()); assertEquals(20, (int) boundingBox.getY()); assertEquals(15, (int) boundingBox.getHeight()); // // Check video track (track-3) // MultimediaContentType track3 = mpeg7.getVideoById("track-3"); MediaTime v2MediaTime = track3.getMediaTime(); // Media locator assertEquals(track3.getMediaLocator().getMediaURI(), URI.create("file:tracks/presenter.mpg")); // Media time point assertEquals(0, v2MediaTime.getMediaTimePoint().getDay()); assertEquals(0, v2MediaTime.getMediaTimePoint().getHour()); assertEquals(0, v2MediaTime.getMediaTimePoint().getMinutes()); assertEquals(0, v2MediaTime.getMediaTimePoint().getSeconds()); assertEquals(25, v2MediaTime.getMediaTimePoint().getFractionsPerSecond()); assertEquals(0, v2MediaTime.getMediaTimePoint().getNFractions()); // Media duration assertEquals(0, v2MediaTime.getMediaDuration().getDays()); assertEquals(1, v2MediaTime.getMediaDuration().getHours()); assertEquals(30, v2MediaTime.getMediaDuration().getMinutes()); assertEquals(0, v2MediaTime.getMediaDuration().getSeconds()); // Segments TemporalDecomposition<VideoSegment> v2Decomposition = (TemporalDecomposition<VideoSegment>) track3 .getTemporalDecomposition(); assertFalse(v2Decomposition.segments().hasNext()); }
From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java
/** * Sets the location of the specified child relative to the location * of the specified parent and then makes it visible, and size to fill window. * This method is mainly useful for windows, frames and dialogs. * // ww w . j ava2 s.co m * @param parentBounds The bounds of the visible parent. * @param child The child to display. * @param max The maximum size of the window. */ public static void setLocationRelativeToAndSizeToWindow(Rectangle parentBounds, Component child, Dimension max) { if (child == null) return; if (parentBounds == null) parentBounds = new Rectangle(0, 0, 5, 5); if (max == null) max = new Dimension(5, 5); int x = (int) (parentBounds.getX() + parentBounds.getWidth()); int y = (int) parentBounds.getY(); int childWidth = child.getWidth(); int childHeight = child.getHeight(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); if (x + childWidth > screenSize.getWidth()) { if (childWidth < parentBounds.getX()) x = (int) (parentBounds.getX()) - childWidth; else x = (int) (screenSize.getWidth() - childWidth); } child.setLocation(x, y); int newHeight = (int) screenSize.getHeight() - y - 10; int newWidth = (int) screenSize.getWidth() - x - 10; if (newWidth > childWidth) childWidth = newWidth; if (newHeight > childHeight) childHeight = newHeight; if (childWidth > max.getWidth()) childWidth = (int) max.getWidth(); if (childHeight > max.getHeight()) childHeight = (int) max.getHeight(); child.setSize(childWidth, childHeight); child.setVisible(true); }