List of usage examples for java.awt.geom AffineTransform getScaleInstance
public static AffineTransform getScaleInstance(double sx, double sy)
From source file:org.apache.pdfbox.pdfviewer.font.CFFGlyph2D.java
/** * Constructor.//from w w w. ja v a 2s .c om * */ public CFFGlyph2D(CFFFont cffFont, Encoding encoding) { fontname = cffFont.getName(); Map<String, Integer> nameToCode = encoding != null ? encoding.getNameToCodeMap() : null; Collection<CFFFont.Mapping> mappings = cffFont.getMappings(); Map<Integer, String> codeToNameMap = new LinkedHashMap<Integer, String>(); for (CFFFont.Mapping mapping : mappings) { codeToNameMap.put(mapping.getCode(), mapping.getName()); } CharStringRenderer renderer = cffFont.createRenderer(); int glyphId = 0; for (CFFFont.Mapping mapping : mappings) { GeneralPath glyph = null; try { glyph = renderer.render(mapping.toType1Sequence()); } catch (IOException exception) { LOG.error("CFF glyph rendering fails!", exception); } if (glyph != null) { AffineTransform atPath = AffineTransform.getScaleInstance(scale, scale); glyph.transform(atPath); glyphs.put(glyphId, transformGlyph(glyph)); int code = mapping.getSID(); String name = mapping.getName(); if (nameToCode != null && nameToCode.containsKey(name)) { code = nameToCode.get(name); } codeToGlyph.put(code, glyphId); glyphId++; } } }
From source file:org.apache.pdfbox.pdfviewer.font.TTFGlyph2D.java
/** * Returns the path describing the glyph for the given glyphId. * * @param glyphId the glyphId//from w w w .j av a 2s. co m * * @return the GeneralPath for the given glyphId */ public GeneralPath getPathForGlyphId(int glyphId) { GeneralPath glyphPath = null; if (glyphs.containsKey(glyphId)) { glyphPath = glyphs.get(glyphId); } else { GlyphData[] glyphData = font.getGlyph().getGlyphs(); if (glyphId < glyphData.length && glyphData[glyphId] != null) { GlyphData glyph = glyphData[glyphId]; GlyphDescription gd = glyph.getDescription(); Point[] points = describe(gd); glyphPath = calculatePath(points); if (hasScaling) { AffineTransform atScale = AffineTransform.getScaleInstance(scale, scale); glyphPath.transform(atScale); } glyphs.put(glyphId, glyphPath); } else { LOG.debug(name + ": Glyph not found:" + glyphId); } } return glyphPath != null ? (GeneralPath) glyphPath.clone() : null; }
From source file:org.apache.pdfbox.rendering.TTFGlyph2D.java
/** * Returns the path describing the glyph for the given glyphId. * * @param gid the GID/*from w w w.jav a 2 s .co m*/ * @param code the character code * * @return the GeneralPath for the given glyphId */ public GeneralPath getPathForGID(int gid, int code) throws IOException { GeneralPath glyphPath; if (glyphs.containsKey(gid)) { glyphPath = glyphs.get(gid); } else { if (gid == 0 || gid >= ttf.getMaximumProfile().getNumGlyphs()) { if (isCIDFont) { int cid = ((PDType0Font) font).codeToCID(code); String cidHex = String.format("%04x", cid); LOG.warn("No glyph for " + code + " (CID " + cidHex + ") in font " + font.getName()); } else { LOG.warn("No glyph for " + code + " in font " + font.getName()); } } GeneralPath glyph = vectorFont.getPath(code); // Acrobat only draws GID 0 for embedded or "Standard 14" fonts, see PDFBOX-2372 if (gid == 0 && !font.isEmbedded() && !font.isStandard14()) { glyph = null; } if (glyph == null) { // empty glyph (e.g. space, newline) glyphPath = new GeneralPath(); glyphs.put(gid, glyphPath); } else { glyphPath = glyph; if (hasScaling) { AffineTransform atScale = AffineTransform.getScaleInstance(scale, scale); glyphPath.transform(atScale); } glyphs.put(gid, glyphPath); } } return glyphPath != null ? (GeneralPath) glyphPath.clone() : null; // todo: expensive }
From source file:org.csstudio.utility.batik.SVGHandler.java
protected void doRender() { if (disposed) { return;/* w w w . j av a2s .c o m*/ } updateMatrix(); changeColor(colorToChange, colorToApply); gvtRoot = builder.build(bridgeContext, svgDocument); // get the 'width' and 'height' attributes of the SVG document float width = 400, height = 400; float docWidth = (float) bridgeContext.getDocumentSize().getWidth(); float docHeight = (float) bridgeContext.getDocumentSize().getHeight(); if (canvasWidth > 0 && canvasHeight > 0) { width = canvasWidth; height = canvasHeight; } else if (canvasHeight > 0) { width = (docWidth * canvasHeight) / docHeight; height = canvasHeight; } else if (canvasWidth > 0) { width = canvasWidth; height = (docHeight * canvasWidth) / docWidth; } else { width = docWidth; height = docHeight; } // compute the preserveAspectRatio matrix AffineTransform renderingTransform = null; AffineTransform Px = null; SVGSVGElement root = svgDocument.getRootElement(); String viewBox = root.getAttributeNS(null, SVGConstants.SVG_VIEW_BOX_ATTRIBUTE); if (viewBox != null && viewBox.length() != 0) { String aspectRatio = root.getAttributeNS(null, SVGConstants.SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE); Px = ViewBox.getPreserveAspectRatioTransform(root, viewBox, aspectRatio, width, height, bridgeContext); } else { // no viewBox has been specified, create a scale transform float xscale = width / docWidth; float yscale = height / docHeight; float scale = Math.min(xscale, yscale); Px = AffineTransform.getScaleInstance(scale, scale); } Shape curAOI = new Rectangle2D.Float(0, 0, width, height); CanvasGraphicsNode cgn = getCanvasGraphicsNode(gvtRoot); if (cgn != null) { cgn.setViewingTransform(Px); renderingTransform = new AffineTransform(); } else { renderingTransform = Px; } if (renderer != null) { renderer.dispose(); renderer = null; } renderer = createImageRenderer(); int w = (int) (curAOI.getBounds().width + 0.5); int h = (int) (curAOI.getBounds().height + 0.5); renderer.updateOffScreen(w, h); renderer.setTree(gvtRoot); renderer.setTransform(renderingTransform); renderer.setDoubleBuffered(false); renderer.clearOffScreen(); renderer.repaint(curAOI); if (updateManager != null) { updateManager.setGVTRoot(gvtRoot); } needRender = false; }
From source file:org.geotools.gce.imagemosaic.RasterLayerResponse.java
/** * This method loads the granules which overlap the requested * {@link GeneralEnvelope} using the provided values for alpha and input * ROI.// w ww. j av a2 s.co m * @return * @throws DataSourceException */ private RenderedImage prepareResponse() throws DataSourceException { try { // // prepare the params for executing a mosaic operation. // // It might important to set the mosaic type to blend otherwise // sometimes strange results jump in. // select the relevant overview, notice that at this time we have // relaxed a bit the requirement to have the same exact resolution // for all the overviews, but still we do not allow for reading the // various grid to world transform directly from the input files, // therefore we are assuming that each granuleDescriptor has a scale and // translate only grid to world that can be deduced from its base // level dimension and envelope. The grid to world transforms for // the other levels can be computed accordingly knowing the scale // factors. if (request.getRequestedBBox() != null && request.getRequestedRasterArea() != null && !request.isHeterogeneousGranules()) imageChoice = ReadParamsController.setReadParams(request.getRequestedResolution(), request.getOverviewPolicy(), request.getDecimationPolicy(), baseReadParameters, request.rasterManager, request.rasterManager.overviewsController); // use general overviews controller else imageChoice = 0; assert imageChoice >= 0; if (LOGGER.isLoggable(Level.FINE)) LOGGER.fine(new StringBuffer("Loading level ").append(imageChoice) .append(" with subsampling factors ").append(baseReadParameters.getSourceXSubsampling()) .append(" ").append(baseReadParameters.getSourceYSubsampling()).toString()); // ok we got something to return, let's load records from the index final BoundingBox cropBBOX = request.getCropBBox(); if (cropBBOX != null) mosaicBBox = ReferencedEnvelope.reference(cropBBOX); else mosaicBBox = new ReferencedEnvelope(coverageEnvelope); //compute final world to grid // base grid to world for the center of pixels final AffineTransform g2w; final OverviewLevel baseLevel = rasterManager.overviewsController.resolutionsLevels.get(0); final OverviewLevel selectedLevel = rasterManager.overviewsController.resolutionsLevels .get(imageChoice); final double resX = baseLevel.resolutionX; final double resY = baseLevel.resolutionY; final double[] requestRes = request.getRequestedResolution(); g2w = new AffineTransform((AffineTransform) baseGridToWorld); g2w.concatenate(CoverageUtilities.CENTER_TO_CORNER); if ((requestRes[0] < resX || requestRes[1] < resY)) { // Using the best available resolution oversampledRequest = true; } else { // SG going back to working on a per level basis to do the composition // g2w = new AffineTransform(request.getRequestedGridToWorld()); g2w.concatenate( AffineTransform.getScaleInstance(selectedLevel.scaleFactor, selectedLevel.scaleFactor)); g2w.concatenate(AffineTransform.getScaleInstance(baseReadParameters.getSourceXSubsampling(), baseReadParameters.getSourceYSubsampling())); } // move it to the corner finalGridToWorldCorner = new AffineTransform2D(g2w); finalWorldToGridCorner = finalGridToWorldCorner.inverse();// compute raster bounds final GeneralEnvelope tempRasterBounds = CRS.transform(finalWorldToGridCorner, mosaicBBox); rasterBounds = tempRasterBounds.toRectangle2D().getBounds(); // SG using the above may lead to problems since the reason is that may be a little (1 px) bigger // than what we need. The code below is a bit better since it uses a proper logic (see GridEnvelope // Javadoc) // rasterBounds = new GridEnvelope2D(new Envelope2D(tempRasterBounds), PixelInCell.CELL_CORNER); if (rasterBounds.width == 0) rasterBounds.width++; if (rasterBounds.height == 0) rasterBounds.height++; if (oversampledRequest) rasterBounds.grow(2, 2); // make sure we do not go beyond the raster dimensions for this layer final GeneralEnvelope levelRasterArea_ = CRS.transform(finalWorldToGridCorner, rasterManager.spatialDomainManager.coverageBBox); final GridEnvelope2D levelRasterArea = new GridEnvelope2D(new Envelope2D(levelRasterArea_), PixelInCell.CELL_CORNER); XRectangle2D.intersect(levelRasterArea, rasterBounds, rasterBounds); // create the index visitor and visit the feature final MosaicBuilder visitor = new MosaicBuilder(request); final List times = request.getRequestedTimes(); final List elevations = request.getElevation(); final Map<String, List> additionalDomains = request.getRequestedAdditionalDomains(); final Filter filter = request.getFilter(); final boolean hasTime = (times != null && times.size() > 0); final boolean hasElevation = (elevations != null && elevations.size() > 0); final boolean hasAdditionalDomains = additionalDomains.size() > 0; final boolean hasFilter = filter != null && !Filter.INCLUDE.equals(filter); // create query final SimpleFeatureType type = rasterManager.granuleCatalog.getType(); Query query = null; Filter bbox = null; if (type != null) { query = new Query(rasterManager.granuleCatalog.getType().getTypeName()); bbox = FeatureUtilities.DEFAULT_FILTER_FACTORY.bbox( FeatureUtilities.DEFAULT_FILTER_FACTORY .property(rasterManager.granuleCatalog.getType().getGeometryDescriptor().getName()), mosaicBBox); query.setFilter(bbox); } else { throw new IllegalStateException("GranuleCatalog feature type was null!!!"); } // prepare eventual filter for filtering granules // handle elevation indexing first since we then combine this with the max in case we are asking for current in time if (hasElevation) { final Filter elevationF = rasterManager.parent.elevationDomainManager .createFilter(ImageMosaicReader.ELEVATION_DOMAIN, elevations); query.setFilter(FeatureUtilities.DEFAULT_FILTER_FACTORY.and(query.getFilter(), elevationF)); } // handle generic filter since we then combine this with the max in case we are asking for current in time if (hasFilter) { query.setFilter(FeatureUtilities.DEFAULT_FILTER_FACTORY.and(query.getFilter(), filter)); } // fuse time query with the bbox query if (hasTime) { final Filter timeFilter = this.rasterManager.parent.timeDomainManager .createFilter(ImageMosaicReader.TIME_DOMAIN, times); query.setFilter(FeatureUtilities.DEFAULT_FILTER_FACTORY.and(query.getFilter(), timeFilter)); } if (hasAdditionalDomains) { final List<Filter> additionalFilter = new ArrayList<Filter>(); for (Entry<String, List> entry : additionalDomains.entrySet()) { // build a filter for each dimension final String domainName = entry.getKey() + DomainDescriptor.DOMAIN_SUFFIX; additionalFilter.add( rasterManager.parent.domainsManager.createFilter(domainName, (List) entry.getValue())); } // merge with existing ones query.setFilter(FeatureUtilities.DEFAULT_FILTER_FACTORY.and(query.getFilter(), FeatureUtilities.DEFAULT_FILTER_FACTORY.and(additionalFilter))); } // // handle secondary query parameters // // max number of elements if (request.getMaximumNumberOfGranules() > 0) { query.setMaxFeatures(request.getMaximumNumberOfGranules()); } // sort by clause final String sortByClause = request.getSortClause(); if (sortByClause != null && sortByClause.length() > 0) { final String[] elements = sortByClause.split(","); if (elements != null && elements.length > 0) { final List<SortBy> clauses = new ArrayList<SortBy>(elements.length); for (String element : elements) { // check if (element == null || element.length() <= 0) { continue;// next, please! } try { // which clause? // ASCENDING element = element.trim(); if (element.endsWith(Utils.ASCENDING_ORDER_IDENTIFIER)) { String attribute = element.substring(0, element.length() - 2); clauses.add( new SortByImpl(FeatureUtilities.DEFAULT_FILTER_FACTORY.property(attribute), SortOrder.ASCENDING)); } else // DESCENDING if (element.contains(Utils.DESCENDING_ORDER_IDENTIFIER)) { String attribute = element.substring(0, element.length() - 2); clauses.add( new SortByImpl(FeatureUtilities.DEFAULT_FILTER_FACTORY.property(attribute), SortOrder.DESCENDING)); } // if(element.startsWith(Utils.ASCENDING_ORDER_IDENTIFIER)){ // String attribute=element.substring(Utils.ASCENDING_ORDER_IDENTIFIER.length()+1); // attribute=attribute.substring(0, attribute.length()-1); // clauses.add(new SortByImpl(FeatureUtilities.DEFAULT_FILTER_FACTORY.property(attribute),SortOrder.ASCENDING)); // } else // // DESCENDING // if(element.startsWith(Utils.DESCENDING_ORDER_IDENTIFIER)){ // String attribute=element.substring(Utils.DESCENDING_ORDER_IDENTIFIER.length()+1); // attribute=attribute.substring(0, attribute.length()-1); // clauses.add(new SortByImpl(FeatureUtilities.DEFAULT_FILTER_FACTORY.property(attribute),SortOrder.DESCENDING)); // } else { else { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Ignoring sort clause :" + element); } } } catch (Exception e) { if (LOGGER.isLoggable(Level.INFO)) { LOGGER.log(Level.INFO, e.getLocalizedMessage(), e); } } } // assign to query if sorting is supported! final SortBy[] sb = clauses.toArray(new SortBy[] {}); if (rasterManager.granuleCatalog.getQueryCapabilities().supportsSorting(sb)) { query.setSortBy(sb); } } } // collect granules rasterManager.getGranules(query, visitor); // get those granules visitor.produce(); // // Did we actually load anything?? Notice that it might happen that // either we have holes inside the definition area for the mosaic // or we had some problem with missing tiles, therefore it might // happen that for some bboxes we don't have anything to load. // RenderedImage returnValue = null; if (visitor.granulesNumber >= 1) { // // Create the mosaic image by doing a crop if necessary and also // managing the transparent color if applicable. Be aware that // management of the transparent color involves removing // transparency information from the input images. // returnValue = buildMosaic(visitor); if (returnValue != null) { if (LOGGER.isLoggable(Level.FINE)) LOGGER.fine("Loaded bbox " + mosaicBBox.toString() + " while crop bbox " + request.getCropBBox().toString()); return returnValue; } } // Redo the query without filter to check whether we got no granules due // to a filter. In that case we need to return null if (hasTime || hasElevation || hasFilter || hasAdditionalDomains) { query.setFilter(bbox); rasterManager.getGranules(query, visitor); // get those granules visitor.produce(); if (visitor.granulesNumber >= 1) { // It means the previous lack of granule was due to a filter excluding all the results. Then we return null return null; } } if (LOGGER.isLoggable(Level.FINE)) LOGGER.fine("Creating constant image for area with no data"); // if we get here that means that we do not have anything to load // but still we are inside the definition area for the mosaic, // therefore we create a fake coverage using the background values, // if provided (defaulting to 0), as well as the compute raster // bounds, envelope and grid to world. final Number[] values = ImageUtilities.getBackgroundValues(rasterManager.defaultSM, backgroundValues); // create a constant image with a proper layout RenderedImage finalImage = ConstantDescriptor.create(Float.valueOf(rasterBounds.width), Float.valueOf(rasterBounds.height), values, null); if (rasterBounds.x != 0 || rasterBounds.y != 0) { finalImage = TranslateDescriptor.create(finalImage, Float.valueOf(rasterBounds.x), Float.valueOf(rasterBounds.y), Interpolation.getInstance(Interpolation.INTERP_NEAREST), null); } if (rasterManager.defaultCM != null) { final ImageLayout2 il = new ImageLayout2(); il.setColorModel(rasterManager.defaultCM); Dimension tileSize = request.getTileDimensions(); if (tileSize == null) { tileSize = JAI.getDefaultTileSize(); } il.setSampleModel( rasterManager.defaultCM.createCompatibleSampleModel(tileSize.width, tileSize.height)); il.setTileGridXOffset(0).setTileGridYOffset(0).setTileWidth((int) tileSize.getWidth()) .setTileHeight((int) tileSize.getHeight()); return FormatDescriptor.create(finalImage, Integer.valueOf(il.getSampleModel(null).getDataType()), new RenderingHints(JAI.KEY_IMAGE_LAYOUT, il)); } return finalImage; } catch (Exception e) { throw new DataSourceException("Unable to create this mosaic", e); } }
From source file:org.github.jipsg.sanselan.BaseSanselanTest.java
/** * Some quick and dirty image scaling - please note that for best performance * and quality you should use image rescaling libraries. *///from w w w . ja v a 2 s .c om @Override public BufferedImage resample(BufferedImage bufferedImage, int width, int height) { Dimension imageDimension = new Dimension(bufferedImage.getWidth(), bufferedImage.getHeight()); Dimension boundaryDimension = new Dimension(width, height); Dimension scaledDimension = BufferedImageUtils.getScaledDimension(imageDimension, boundaryDimension); double scaleX = scaledDimension.getWidth() / bufferedImage.getWidth(); double scaleY = scaledDimension.getHeight() / bufferedImage.getHeight(); AffineTransform scaleTransform = AffineTransform.getScaleInstance(scaleX, scaleY); AffineTransformOp biLinearScaleOp = new AffineTransformOp(scaleTransform, AffineTransformOp.TYPE_BILINEAR); return biLinearScaleOp.filter(bufferedImage, new BufferedImage(scaledDimension.width, scaledDimension.height, bufferedImage.getType())); }
From source file:org.h819.commons.file.MyPDFUtilss.java
/** * pdf ? pdf//from ww w .j a v a2s .c o m * * @param srcPdf the original PDF * @param destPdf the resulting PDF * @param imageFactor The multiplication factor for the image (? imageFacto =0.5f) * @throws IOException * @throws DocumentException */ public static void compressPdf(File srcPdf, File destPdf, float imageFactor) throws IOException, DocumentException { PdfReader reader = new PdfReader(srcPdf.getAbsolutePath()); int n = reader.getXrefSize(); PdfObject object; PRStream stream; // Look for image and manipulate image stream for (int i = 0; i < n; i++) { object = reader.getPdfObject(i); if (object == null || !object.isStream()) continue; stream = (PRStream) object; if (!PdfName.IMAGE.equals(stream.getAsName(PdfName.SUBTYPE))) continue; if (!PdfName.DCTDECODE.equals(stream.getAsName(PdfName.FILTER))) continue; PdfImageObject image = new PdfImageObject(stream); BufferedImage bi = image.getBufferedImage(); if (bi == null) continue; int width = (int) (bi.getWidth() * imageFactor); int height = (int) (bi.getHeight() * imageFactor); if (width <= 0 || height <= 0) continue; BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); AffineTransform at = AffineTransform.getScaleInstance(imageFactor, imageFactor); Graphics2D g = img.createGraphics(); g.drawRenderedImage(bi, at); ByteArrayOutputStream imgBytes = new ByteArrayOutputStream(); ImageIO.write(img, "JPG", imgBytes); stream.clear(); stream.setData(imgBytes.toByteArray(), false, PRStream.NO_COMPRESSION); stream.put(PdfName.TYPE, PdfName.XOBJECT); stream.put(PdfName.SUBTYPE, PdfName.IMAGE); stream.put(PdfName.FILTER, PdfName.DCTDECODE); stream.put(PdfName.WIDTH, new PdfNumber(width)); stream.put(PdfName.HEIGHT, new PdfNumber(height)); stream.put(PdfName.BITSPERCOMPONENT, new PdfNumber(8)); stream.put(PdfName.COLORSPACE, PdfName.DEVICERGB); } reader.removeUnusedObjects(); // Save altered PDF PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(destPdf.getAbsolutePath())); stamper.setFullCompression(); stamper.close(); reader.close(); }
From source file:org.jcurl.core.base.CurveTransformedTest.java
public void testAffineTransformMemoryLayout() { Rock r = new RockDouble(1, 2, 3); AffineTransform at = new AffineTransform(); final double[] d = new double[6]; at.getMatrix(d);/*from w w w. j av a 2 s . c o m*/ assertEquals("", 1.0, d[0], 1e-9); assertEquals("", 0.0, d[1], 1e-9); assertEquals("", 0.0, d[2], 1e-9); assertEquals("", 1.0, d[3], 1e-9); assertEquals("", 0.0, d[4], 1e-9); assertEquals("", 0.0, d[5], 1e-9); at.transform(r = new RockDouble(2, 3, 4), r); assertEquals(2, 3, 4, r, 1e-9); at = AffineTransform.getScaleInstance(0.5, 0.75); at.getMatrix(d); assertEquals("", 0.5, d[0], 1e-9); assertEquals("", 0.0, d[1], 1e-9); assertEquals("", 0.0, d[2], 1e-9); assertEquals("", 0.75, d[3], 1e-9); assertEquals("", 0.0, d[4], 1e-9); assertEquals("", 0.0, d[5], 1e-9); at.transform(r = new RockDouble(2, 3, 4), r); assertEquals(1, 2.25, 4, r, 1e-9); at = AffineTransform.getTranslateInstance(0.5, 0.75); at.getMatrix(d); assertEquals("", 1.0, d[0], 1e-9); assertEquals("", 0.0, d[1], 1e-9); assertEquals("", 0.0, d[2], 1e-9); assertEquals("", 1.0, d[3], 1e-9); assertEquals("", 0.5, d[4], 1e-9); assertEquals("", 0.75, d[5], 1e-9); at.transform(r = new RockDouble(2, 3, 4), r); assertEquals(2.5, 3.75, 4, r, 1e-9); }
From source file:org.jcurl.core.base.CurveTransformedTest.java
public void testValueC0() throws MathException { Rock ret = null;//from www . ja va 2 s . c o m final AffineTransform at = AffineTransform.getScaleInstance(0.75, 1.25); final CurveTransformed cw = new CurveTransformed(new CurveRock() { @Override public double at(int component, int derivative, double t) { switch (component) { case 0: return t * 2.0; case 1: return t * 1.5; case 2: return t * 0.5; default: throw new IllegalArgumentException(); } } }, at, 0); ret = cw.at(0, 0, ret); assertEquals(0, 0, 0, ret, 1e-9); ret = cw.at(0, 0.5, ret); assertEquals(0.75, 0.9375, 0.25, ret, 1e-9); ret = cw.at(0, 1.0, ret); assertEquals(1.5, 1.875, 0.5, ret, 1e-9); ret = cw.at(0, 1.5, ret); assertEquals(2.25, 2.8125, 0.75, ret, 1e-9); }
From source file:org.jcurl.demo.tactics.TrajectoryScenarioBean.java
public TrajectoryScenarioBean() { setVisible(false);/*from w w w . j av a 2 s . co m*/ broom.setModel(tt); panel = new JSGPanel(); setLayout(new BorderLayout()); add(panel, BorderLayout.CENTER); final SGGroup world = new SGGroup(); world.add(new SGIceFactory.Fancy().newInstance()); // rocks.setVisible(false); final SGGroup r0 = new SGGroup(); final SGGroup r1 = new SGGroup(); final SGGroup pa = new SGGroup(); // rocks.add(traj); final RockSet<Pos> home = RockSetUtils.allHome(); final RockSet<Pos> out = RockSetUtils.allOut(); for (int i16 = RockSet.ROCKS_PER_SET - 1; i16 >= 0; i16--) { Affine n = createSceneRock(home, i16, 255); n.setMouseBlocker(true); n.addMouseListener(mouse); n.setCursor(CURSOR); r0.add(initial[i16] = n); r1.add(current[i16] = n = createSceneRock(out, i16, 255)); n.putAttribute(ATTR_TRIGGER_CURVE_UPDATE, true); pa.add(path[i16] = new SGGroup()); } if (false) { rocks.add(pa); rocks.add(r0); rocks.add(r1); } else { opa_r0.setChild(r0); opa_r0.setOpacity(64.0F / 255.0F); opa_r0.setOverlapBehavior(OverlapBehavior.LAYER); opa_r1.setChild(r1); opa_r1.setOverlapBehavior(OverlapBehavior.LAYER); opa_t0.setChild(pa); opa_t0.setMouseBlocker(true); opa_t0.setOverlapBehavior(OverlapBehavior.LAYER); opa_t0.setOpacity(100.0F / 255.0F); rocks.add(opa_t0); rocks.add(opa_r0); rocks.add(opa_r1); } rocks.add(broom.getScene()); rocks.setVisible(false); world.add(rocks); // make world right-handed: final AffineTransform rightHand = AffineTransform.getScaleInstance(1, -1); zoom = SGTransform.createAffine(new AffineTransform(), dc2wc = SGTransform.createAffine(rightHand, world)); broom.setDc2wc(dc2wc); panel.setScene(zoom); setVisible(true); }