List of usage examples for java.awt.geom Rectangle2D getMinX
public double getMinX()
From source file:org.mrgeo.utils.Bounds.java
public Bounds(Rectangle2D from) { minX = from.getMinX(); minY = from.getMinY(); maxX = from.getMaxX(); maxY = from.getMaxY(); set = true; }
From source file:org.n52.oxf.serialization.XmlBeansContextWriter.java
private void serialize(ContextBoundingBox bboxToSerialize) { Rectangle2D actualBBox = bboxToSerialize.getActualBBox(); BoundingBoxType xb_bbox = BoundingBoxType.Factory.newInstance(); xb_bbox.setMaxx(new BigDecimal(actualBBox.getMaxX())); xb_bbox.setMinx(new BigDecimal(actualBBox.getMinX())); xb_bbox.setMaxy(new BigDecimal(actualBBox.getMaxY())); xb_bbox.setMiny(new BigDecimal(actualBBox.getMinY())); xb_bbox.setSRS(bboxToSerialize.getSRS()); builder.append(xb_bbox.toString());//from ww w .j a v a 2s .c o m }
From source file:org.opensha.commons.geo.GriddedRegion.java
private List<Integer> indexLookupFast(Rectangle2D rect) { checkArgument(area.contains(rect));// ww w. ja v a2 s . c om Location pLL = new Location(rect.getMinY(), rect.getMinX()); Location pUL = new Location(rect.getMaxY(), rect.getMinX()); Location pLR = new Location(rect.getMinY(), rect.getMaxX()); int idxLL = indexForLocation(pLL); int idxUL = indexForLocation(pUL); int idxLR = indexForLocation(pLR); // indices of row starts List<Integer> rowStarts = Lists.newArrayList(); int rowStartIdx = idxLL; int lastRowStartIdx = idxUL; while (rowStartIdx <= lastRowStartIdx) { rowStarts.add(rowStartIdx); Location currLoc = locationForIndex(rowStartIdx); Location nextLoc = new Location(currLoc.getLatitude() + latSpacing, currLoc.getLongitude()); rowStartIdx = indexForLocation(nextLoc); } // row length int len = idxLR - idxLL + 1; // build list List<Integer> indices = Lists.newArrayList(); for (Integer idx : rowStarts) { addRange(indices, idx, len); } return indices; }
From source file:org.orbisgis.view.map.tools.InfoTool.java
@Override protected void rectangleDone(Rectangle2D rect, boolean smallerThanTolerance, MapContext vc, ToolManager tm) throws TransitionException { ILayer layer = vc.getSelectedLayers()[0]; DataSource sds = layer.getDataSource(); try {/*from w w w . j av a 2s . c om*/ double minx = rect.getMinX(); double miny = rect.getMinY(); double maxx = rect.getMaxX(); double maxy = rect.getMaxY(); BackgroundManager bm = Services.getService(BackgroundManager.class); bm.backgroundOperation(new DefaultJobId("org.orbisgis.jobs.InfoTool"), new PopulateViewJob(new Envelope(minx, maxx, miny, maxy), sds)); } catch (DriverLoadException e) { throw new RuntimeException(e); } }
From source file:org.photovault.image.ImageOpChain.java
/** * Helper function to apply Photovault style cropping to this chain * @param cropBounds Crop bounds./* w w w . j a v a2s .c om*/ */ public void applyCropping(Rectangle2D cropBounds) { CropOp crop = (CropOp) getOperation("crop"); if (crop == null) { crop = createCropOp(); } crop.setMinX(cropBounds.getMinX()); crop.setMaxX(cropBounds.getMaxX()); crop.setMinY(cropBounds.getMinY()); crop.setMaxY(cropBounds.getMaxY()); }
From source file:org.photovault.image.PhotovaultImage.java
/** Set new crop bounds for the image. Crop bounds are applied after rotation, so that top left corner is (0, 0) and bottom right corner (1, 1) @param c New crop bounds/*from w w w . ja v a 2 s .c o m*/ */ public void setCropBounds(Rectangle2D c) { cropMinX = Math.min(1.0, Math.max(0.0, c.getMinX())); cropMinY = Math.min(1.0, Math.max(0.0, c.getMinY())); cropMaxX = Math.min(1.0, Math.max(0.0, c.getMaxX())); cropMaxY = Math.min(1.0, Math.max(0.0, c.getMaxY())); if (cropMaxX - cropMinX <= 0.0) { double tmp = cropMaxX; cropMaxX = cropMinX; cropMinX = tmp; } if (cropMaxY - cropMinY <= 0.0) { double tmp = cropMaxY; cropMaxY = cropMinY; cropMinY = tmp; } applyRotCrop(); }
From source file:org.photovault.imginfo.ChangePhotoInfoCommand.java
/** Execute the command.//from ww w . j av a 2 s. c o m */ public void execute() throws CommandException { StringBuffer debugMsg = null; if (log.isDebugEnabled()) { debugMsg = new StringBuffer(); debugMsg.append("execute()"); boolean isFirst = true; for (UUID id : photoUuids) { debugMsg.append(isFirst ? "Photo ids: " : ", "); debugMsg.append(id); } debugMsg.append("\n"); debugMsg.append("Changed values:\n"); for (Map.Entry<String, Object> e : changedFields.entrySet()) { String field = e.getKey(); Object value = e.getValue(); debugMsg.append(field).append(": ").append(value).append("\n"); } log.debug(debugMsg); } PhotoInfoDAO photoDAO = daoFactory.getPhotoInfoDAO(); Set<PhotoInfo> photos = new HashSet<PhotoInfo>(); if (photoUuids.size() == 0) { PhotoInfo photo = photoDAO.create(); photos.add(photo); } else { for (UUID id : photoUuids) { PhotoInfo photo = photoDAO.findByUUID(id); photos.add(photo); } } changedPhotos = new HashSet<PhotoInfo>(); Set<PhotoInfoFields> rawSettingsFields = EnumSet.range(PhotoInfoFields.RAW_BLACK_LEVEL, PhotoInfoFields.RAW_COLOR_PROFILE); Set<PhotoInfoFields> colorCurveFields = EnumSet.range(PhotoInfoFields.COLOR_CURVE_VALUE, PhotoInfoFields.COLOR_CURVE_SATURATION); Set<PhotoInfoFields> cropFields = EnumSet.of(PhotoInfoFields.CROP_BOUNDS, PhotoInfoFields.PREF_ROTATION); DTOResolverFactory resolverFactory = daoFactory.getDTOResolverFactory(); for (PhotoInfo photo : photos) { /* Ensure that this photo is persistence & the instance belongs to current persistence context */ changedPhotos.add(photo); VersionedObjectEditor<PhotoInfo> pe = new VersionedObjectEditor(photo, resolverFactory); PhotoEditor pep = (PhotoEditor) pe.getProxy(); RawSettingsFactory rawSettingsFactory = null; ChannelMapOperationFactory channelMapFactory = null; // New processing operations ImageOpChain procChain = photo.getProcessing(); ProcGraphEditorHelper rawConvHelper = null; ProcGraphEditorHelper rawMapHelper = null; ProcGraphEditorHelper chanMapHelper = null; ProcGraphEditorHelper cropHelper = null; try { rawConvHelper = new ProcGraphEditorHelper(pe, "dcraw", DCRawOp.class); rawMapHelper = new ProcGraphEditorHelper(pe, "raw-map", DCRawMapOp.class); chanMapHelper = new ProcGraphEditorHelper(pe, "chan-map", ChanMapOp.class); cropHelper = new ProcGraphEditorHelper(pe, "crop", CropOp.class); } catch (IllegalAccessException ex) { // Should not happen log.error(ex); throw new CommandException("Unexpected problem instantiating processing grap helpers", ex); } catch (InstantiationException ex) { // Should not happen log.error(ex); throw new CommandException("Unexpected problem instantiating processing grap helpers", ex); } for (Map.Entry<String, SetChange> e : modifiedSets.entrySet()) { for (Object val : e.getValue().added) { pe.addToSet(e.getKey(), val); } for (Object val : e.getValue().removed) { pe.removeFromSet(e.getKey(), val); } } for (Map.Entry<String, Object> e : changedFields.entrySet()) { String fieldName = e.getKey(); PhotoInfoFields field = PhotoInfoFields.getByName(fieldName); Object value = e.getValue(); try { if (rawSettingsFields.contains(field)) { this.setRawField(rawConvHelper, rawMapHelper, field, value); } else if (colorCurveFields.contains(field)) { setColorMapField(chanMapHelper, field, value); } else if (field == PhotoInfoFields.CROP_BOUNDS) { Rectangle2D cropRect = (Rectangle2D) e.getValue(); cropHelper.setProperty("minX", cropRect.getMinX()); cropHelper.setProperty("maxX", cropRect.getMaxX()); cropHelper.setProperty("minY", cropRect.getMinY()); cropHelper.setProperty("maxY", cropRect.getMaxY()); } else if (field == PhotoInfoFields.PREF_ROTATION) { Double rot = (Double) e.getValue(); cropHelper.setProperty("rot", rot); } else { pe.setField(fieldName, e.getValue()); } } catch (IllegalAccessException ex) { log.error("exception while setting field " + field, ex); throw new CommandException("Illegal access while setting field " + field, ex); } catch (InvocationTargetException ex) { log.error("exception while setting field " + field, ex); throw new CommandException("Invocation target exception while setting field " + field, ex); } catch (NoSuchMethodException ex) { log.error("exception while setting field " + field, ex); throw new CommandException("Non-existing method called while setting field " + field, ex); } } ProcGraphEditorHelper[] chain = new ProcGraphEditorHelper[] { rawConvHelper, rawMapHelper, chanMapHelper, cropHelper }; String nextNodeInput = null; for (int n = chain.length - 1; n >= 0; n--) { String sourcePort = null; // Find the node that should be connected to input of current node for (int m = n - 1; m >= 0; m--) { if (chain[m].isNodeAlreadyPresent()) { sourcePort = chain[m].getNodeName() + ".out"; break; } } ProcGraphEditorHelper node = chain[n]; if (node.isNodeAlreadyPresent() || node.addNewNode(sourcePort, nextNodeInput)) { nextNodeInput = node.getNodeName() + ".in"; } } PhotoFolderDAO folderDAO = daoFactory.getPhotoFolderDAO(); FolderPhotoAssocDAO assocDAO = daoFactory.getFolderPhotoAssocDAO(); Set<PhotoFolder> af = new HashSet<PhotoFolder>(); for (UUID folderId : addedToFolders) { log.debug("Adding photo " + photo.getUuid() + " to folder " + folderId); PhotoFolder folder = folderDAO.findById(folderId, false); VersionedObjectEditor<PhotoFolder> fe = new VersionedObjectEditor<PhotoFolder>(folder, resolverFactory); FolderEditor fep = (FolderEditor) fe.getProxy(); FolderPhotoAssociation a = assocDAO.getAssociation(folder, photo); pep.addFolderAssociation(a); fep.addPhotoAssociation(a); Change<PhotoFolder> ch = fe.apply(); changes.add(new ChangeDTO<PhotoFolder>(ch)); af.add(folder); } Set<PhotoFolder> rf = new HashSet<PhotoFolder>(); Set<FolderPhotoAssociation> deletedAssocs = new HashSet<FolderPhotoAssociation>(); for (UUID folderId : removedFromFolders) { log.debug("Removing photo " + photo.getUuid() + " from folder " + folderId); PhotoFolder folder = folderDAO.findById(folderId, false); VersionedObjectEditor<PhotoFolder> fe = new VersionedObjectEditor<PhotoFolder>(folder, resolverFactory); FolderEditor fep = (FolderEditor) fe.getProxy(); FolderPhotoAssociation a = assocDAO.getAssociation(folder, photo); fep.removePhotoAssociation(a); pep.removeFolderAssociation(a); deletedAssocs.add(a); Change<PhotoFolder> ch = fe.apply(); changes.add(new ChangeDTO<PhotoFolder>(ch)); } Change<PhotoInfo> ch = pe.apply(); changes.add(new ChangeDTO<PhotoInfo>(ch)); for (FolderPhotoAssociation a : deletedAssocs) { assocDAO.makeTransient(a); } } }
From source file:org.photovault.imginfo.XMPConverter.java
/** Create XMP metadata based on given photo and image file @param f The image file, used to initialize media management information @param p The photo used to initialize descriptive fields @return An XMP metadata object initialized based on the given information @throws com.adobe.xmp.XMPException If an error occurs while creating the metadata/*from ww w . j av a2 s . c o m*/ */ public XMPMeta getXMPMetadata(ImageFile f, PhotoInfo p) throws XMPException { XMPMeta meta = XMPMetaFactory.create(); XMPSchemaRegistry reg = XMPMetaFactory.getSchemaRegistry(); // Check for Photovault schemas if (reg.getNamespacePrefix(NS_PV) == null) { try { reg.registerNamespace(NS_PV, "pv"); } catch (XMPException e) { log.error("CMPException: " + e.getMessage()); } } if (reg.getNamespacePrefix(NS_PHOTOSHOP) == null) { try { reg.registerNamespace(NS_PHOTOSHOP, "photoshop"); } catch (XMPException e) { log.error("CMPException: " + e.getMessage()); } } byte[] data = null; try { URI ifileURI = new URI("uuid", f.getId().toString(), null); meta.setProperty(NS_MM, "InstanceID", ifileURI.toString()); meta.setProperty(NS_MM, "Manager", "Photovault 0.5.0dev"); meta.setProperty(NS_MM, "ManageTo", ifileURI.toString()); } catch (URISyntaxException ex) { log.error(ex); } CopyImageDescriptor firstImage = (CopyImageDescriptor) f.getImage("image#0"); OriginalImageDescriptor orig = firstImage.getOriginal(); String rrNS = reg.getNamespaceURI("stRef"); try { URI origURI = new URI("uuid", orig.getFile().getId().toString(), orig.getLocator()); meta.setStructField(NS_MM, "DerivedFrom", rrNS, "InstanceID", origURI.toString()); } catch (URISyntaxException ex) { log.error(ex); } meta.setStructField(NS_MM, "DerivedFrom", NS_PV, "Rotation", Double.toString(firstImage.getRotation())); Rectangle2D cropArea = firstImage.getCropArea(); meta.setStructField(NS_MM, "DerivedFrom", NS_PV, "XMin", Double.toString(cropArea.getMinX())); meta.setStructField(NS_MM, "DerivedFrom", NS_PV, "XMax", Double.toString(cropArea.getMaxX())); meta.setStructField(NS_MM, "DerivedFrom", NS_PV, "YMin", Double.toString(cropArea.getMinY())); meta.setStructField(NS_MM, "DerivedFrom", NS_PV, "YMax", Double.toString(cropArea.getMaxY())); ChannelMapOperation cm = firstImage.getColorChannelMapping(); if (cm != null) { try { ByteArrayOutputStream cms = new ByteArrayOutputStream(); ObjectOutputStream cmos = new ObjectOutputStream(cms); cmos.writeObject(cm); String cmBase64 = Base64.encodeBytes(cms.toByteArray(), Base64.GZIP | Base64.DONT_BREAK_LINES); meta.setStructField(NS_MM, "DerivedFrom", NS_PV, "ChannelMap", cmBase64); } catch (IOException e) { log.error("Error serializing channel map", e); } } RawConversionSettings rs = firstImage.getRawSettings(); if (rs != null) { try { ByteArrayOutputStream rss = new ByteArrayOutputStream(); ObjectOutputStream rsos = new ObjectOutputStream(rss); rsos.writeObject(rs); String rsBase64 = Base64.encodeBytes(rss.toByteArray(), Base64.GZIP | Base64.DONT_BREAK_LINES); meta.setStructField(NS_MM, "DerivedFrom", NS_PV, "RawConversion", rsBase64); } catch (IOException e) { log.error("Error serializing raw settings", e); } } /* Set the image metadata based the photo we are creating this copy. There may be other photos associated with the origial image file, so we should store information about these in some proprietary part of metadata. */ meta.appendArrayItem(NS_DC, "creator", new PropertyOptions().setArrayOrdered(true), p.getPhotographer(), null); meta.setProperty(NS_DC, "description", p.getDescription()); double fstop = p.getFStop(); if (fstop > 0.0) { String aperture = floatToRational(p.getFStop()); meta.setProperty(NS_EXIF, "ApertureValue", aperture); meta.setProperty(NS_EXIF, "FNumber", aperture); } // String film = photo.getFilm(); int isoSpeed = p.getFilmSpeed(); if (isoSpeed > 0) { meta.appendArrayItem(NS_EXIF, "ISOSpeedRatings", new PropertyOptions().setArrayOrdered(true), String.valueOf(isoSpeed), null); } double focalLength = p.getFocalLength(); if (focalLength > 0.0) { meta.setProperty(NS_EXIF, "FocalLength", floatToRational(focalLength)); } int quality = p.getQuality(); meta.setPropertyDouble(NS_XMP_BASIC, "Rating", (double) quality); /* XMP location needs to be formal hierachical place, so we will store * this as a keyword. */ PropertyOptions subjectOptions = new PropertyOptions(PropertyOptions.ARRAY); String shootingPlace = p.getShootingPlace(); if (shootingPlace != null) { meta.appendArrayItem(NS_DC, "subject", subjectOptions, shootingPlace, null); } for (Tag tag : p.getTags()) { meta.appendArrayItem(NS_DC, "subject", subjectOptions, tag.getName(), null); } double expTime = p.getShutterSpeed(); if (expTime > 0.0) { String shutterSpeed = expTimeAsRational(expTime); meta.setProperty(NS_EXIF, "ExposureTme", shutterSpeed); } // photo.getTechNotes(); Date shootDate = p.getShootTime(); if (shootDate != null) { DateFormat dfmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); String xmpShootDate = dfmt.format(shootDate); meta.setProperty(NS_XMP_BASIC, "CreateDate", xmpShootDate); meta.setProperty(NS_PHOTOSHOP, "DateCreated", xmpShootDate); } // Save technical data meta.setProperty(NS_TIFF, "Model", p.getCamera()); meta.setProperty(NS_EXIF_AUX, "Lens", p.getLens()); // TODO: add other photo attributes as well // Add names of the folders the photo belongs to as keywords for (PhotoFolder folder : p.getFolders()) { if (folder.getExternalDir() == null) { meta.appendArrayItem(NS_DC, "subject", subjectOptions, folder.getName(), null); } } // Save the history of the image ObjectHistory<PhotoInfo> h = p.getHistory(); ObjectHistoryDTO<PhotoInfo> hdto = new ObjectHistoryDTO<PhotoInfo>(h); ByteArrayOutputStream histStream = new ByteArrayOutputStream(); try { ObjectOutputStream histoStream = new ObjectOutputStream(histStream); histoStream.writeObject(hdto); histoStream.flush(); histStream.flush(); byte histData[] = histStream.toByteArray(); String histBase64 = Base64.encodeBytes(histData, Base64.GZIP | Base64.DONT_BREAK_LINES); meta.setProperty(NS_PV, "History", histBase64); } catch (IOException e) { log.warn("Error serializing history", e); } return meta; }
From source file:org.photovault.swingui.PhotoCollectionThumbView.java
private void paintThumbnail(Graphics2D g2, PhotoInfo photo, int startx, int starty, boolean isSelected) { log.debug("paintThumbnail entry " + photo.getUuid()); long startTime = System.currentTimeMillis(); long thumbReadyTime = 0; long thumbDrawnTime = 0; long endTime = 0; // Current position in which attributes can be drawn int ypos = starty + rowHeight / 2; boolean useOldThumbnail = false; Thumbnail thumbnail = null;//from ww w .j a v a 2 s. c o m log.debug("finding thumb"); boolean hasThumbnail = photo.hasThumbnail(); log.debug("asked if has thumb"); if (hasThumbnail) { log.debug("Photo " + photo.getUuid() + " has thumbnail"); thumbnail = photo.getThumbnail(); log.debug("got thumbnail"); } else { /* Check if the thumbnail has been just invalidated. If so, use the old one until we get the new thumbnail created. */ thumbnail = photo.getOldThumbnail(); if (thumbnail != null) { useOldThumbnail = true; } else { // No success, use default thumnail. thumbnail = Thumbnail.getDefaultThumbnail(); } // Inform background task scheduler that we have some work to do ctrl.getBackgroundTaskScheduler().registerTaskProducer(this, TaskPriority.CREATE_VISIBLE_THUMBNAIL); } thumbReadyTime = System.currentTimeMillis(); log.debug("starting to draw"); // Find the position for the thumbnail BufferedImage img = thumbnail.getImage(); if (img == null) { thumbnail = Thumbnail.getDefaultThumbnail(); img = thumbnail.getImage(); } float scaleX = ((float) thumbWidth) / ((float) img.getWidth()); float scaleY = ((float) thumbHeight) / ((float) img.getHeight()); float scale = Math.min(scaleX, scaleY); int w = (int) (img.getWidth() * scale); int h = (int) (img.getHeight() * scale); int x = startx + (columnWidth - w) / (int) 2; int y = starty + (rowHeight - h) / (int) 2; log.debug("drawing thumbnail"); // Draw shadow int offset = isSelected ? 2 : 0; int shadowX[] = { x + 3 - offset, x + w + 1 + offset, x + w + 1 + offset }; int shadowY[] = { y + h + 1 + offset, y + h + 1 + offset, y + 3 - offset }; GeneralPath polyline = new GeneralPath(GeneralPath.WIND_EVEN_ODD, shadowX.length); polyline.moveTo(shadowX[0], shadowY[0]); for (int index = 1; index < shadowX.length; index++) { polyline.lineTo(shadowX[index], shadowY[index]); } ; BasicStroke shadowStroke = new BasicStroke(4.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER); Stroke oldStroke = g2.getStroke(); g2.setStroke(shadowStroke); g2.setColor(Color.DARK_GRAY); g2.draw(polyline); g2.setStroke(oldStroke); // Paint thumbnail g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); g2.drawImage(img, new AffineTransform(scale, 0f, 0f, scale, x, y), null); if (useOldThumbnail) { creatingThumbIcon.paintIcon(this, g2, startx + (columnWidth - creatingThumbIcon.getIconWidth()) / (int) 2, starty + (rowHeight - creatingThumbIcon.getIconHeight()) / (int) 2); } log.debug("Drawn, drawing decorations"); if (isSelected) { Stroke prevStroke = g2.getStroke(); Color prevColor = g2.getColor(); g2.setStroke(new BasicStroke(3.0f)); g2.setColor(Color.BLUE); g2.drawRect(x, y, w, h); g2.setColor(prevColor); g2.setStroke(prevStroke); } thumbDrawnTime = System.currentTimeMillis(); boolean drawAttrs = (thumbWidth >= 100); if (drawAttrs) { // Increase ypos so that attributes are drawn under the image ypos += ((int) h) / 2 + 3; // Draw the attributes // Draw the qualoity icon to the upper left corner of the thumbnail int quality = photo.getQuality(); if (showQuality && quality != 0) { int qx = startx + (columnWidth - quality * starIcon.getIconWidth()) / (int) 2; for (int n = 0; n < quality; n++) { starIcon.paintIcon(this, g2, qx, ypos); qx += starIcon.getIconWidth(); } ypos += starIcon.getIconHeight(); } ypos += 6; if (photo.getRawSettings() != null) { // Draw the "RAW" icon int rx = startx + (columnWidth + w - rawIcon.getIconWidth()) / (int) 2 - 5; int ry = starty + (columnWidth - h - rawIcon.getIconHeight()) / (int) 2 + 5; rawIcon.paintIcon(this, g2, rx, ry); } if (photo.getHistory().getHeads().size() > 1) { // Draw the "unresolved conflicts" icon int rx = startx + (columnWidth + w - 10) / (int) 2 - 20; int ry = starty + (columnWidth - h - 10) / (int) 2; g2.setColor(Color.RED); g2.fillRect(rx, ry, 10, 10); } Color prevBkg = g2.getBackground(); if (isSelected) { g2.setBackground(Color.BLUE); } else { g2.setBackground(this.getBackground()); } Font attrFont = new Font("Arial", Font.PLAIN, 10); FontRenderContext frc = g2.getFontRenderContext(); if (showDate && photo.getShootTime() != null) { FuzzyDate fd = new FuzzyDate(photo.getShootTime(), photo.getTimeAccuracy()); String dateStr = fd.format(); TextLayout txt = new TextLayout(dateStr, attrFont, frc); // Calculate the position for the text Rectangle2D bounds = txt.getBounds(); int xpos = startx + ((int) (columnWidth - bounds.getWidth())) / 2 - (int) bounds.getMinX(); g2.clearRect(xpos - 2, ypos - 2, (int) bounds.getWidth() + 4, (int) bounds.getHeight() + 4); txt.draw(g2, xpos, (int) (ypos + bounds.getHeight())); ypos += bounds.getHeight() + 4; } String shootPlace = photo.getShootingPlace(); if (showPlace && shootPlace != null && shootPlace.length() > 0) { TextLayout txt = new TextLayout(photo.getShootingPlace(), attrFont, frc); // Calculate the position for the text Rectangle2D bounds = txt.getBounds(); int xpos = startx + ((int) (columnWidth - bounds.getWidth())) / 2 - (int) bounds.getMinX(); g2.clearRect(xpos - 2, ypos - 2, (int) bounds.getWidth() + 4, (int) bounds.getHeight() + 4); txt.draw(g2, xpos, (int) (ypos + bounds.getHeight())); ypos += bounds.getHeight() + 4; } g2.setBackground(prevBkg); } endTime = System.currentTimeMillis(); log.debug("paintThumbnail: exit " + photo.getUuid()); log.debug("Thumb fetch " + (thumbReadyTime - startTime) + " ms"); log.debug("Thumb draw " + (thumbDrawnTime - thumbReadyTime) + " ms"); log.debug("Deacoration draw " + (endTime - thumbDrawnTime) + " ms"); log.debug("Total " + (endTime - startTime) + " ms"); }
From source file:org.uva.itast.blended.omr.OMRUtils.java
/** * draws a rectangle expressed in milimeters * // ww w . j a va 2s .c om * @param pageImage * @param markArea */ public static void logFrame(PageImage pageImage, Rectangle2D markArea, Color color, String label) { OMRUtils.logFrame(pageImage, new PagePoint(pageImage, markArea.getMinX(), markArea.getMinY()), new PagePoint(pageImage, markArea.getMaxX(), markArea.getMinY()), new PagePoint(pageImage, markArea.getMinX(), markArea.getMaxY()), new PagePoint(pageImage, markArea.getMaxX(), markArea.getMaxY()), color, label); }