void pruneLevel() { // Traverse any children. if ( this.numChildren > 0 ) for ( int id = 0; id < MAX_CHILDREN; id++ ) if ( this.children[id] != null ) this.children[id].pruneLevel(); if ( this.level == this.cube.depth ) prune(); }
public static BufferedImage quantizeImage( BufferedImage image, int maxColors, boolean dither, boolean alphaToBitmask ) { Cube cube = new Cube( maxColors ); cube.classifyImageColors( image, alphaToBitmask ); cube.reduceImageColors( maxColors ); return cube.assignImageColors( image, dither, alphaToBitmask ); }
/** * @param req * should be a GetMap or GetLegendGraphic * @return an empty image conforming to the request parameters */ public static BufferedImage prepareImage( Object req ) { String format = null; int width = 0, height = 0; Color bgcolor = null; boolean transparent = false; if ( req instanceof GetLegendGraphic ) { GetLegendGraphic glg = (GetLegendGraphic) req; format = glg.getFormat(); width = glg.getWidth(); height = glg.getHeight(); transparent = true; } else { return null; } return ImageUtils.prepareImage( format, width, height, transparent, bgcolor ); }
void pruneToCubeDepth() { // Traverse any children. if ( this.numChildren > 0 ) for ( int id = 0; id < MAX_CHILDREN; id++ ) if ( this.children[id] != null ) this.children[id].pruneToCubeDepth(); if ( this.level > this.cube.depth ) prune(); }
/** * @param mark * @param size * @param rotation * @return a shape representing the mark */ public static Shape getShapeFromMark( Mark mark, double size, double rotation ) { return getShapeFromMark( mark, size, rotation, false, -1, -1 ); }
void reduce( long pruningThreshold ) { // Traverse any children. if ( this.numChildren > 0 ) for ( int id = 0; id < MAX_CHILDREN; id++ ) if ( this.children[id] != null ) this.children[id].reduce( pruningThreshold ); if ( this.quantizeError <= pruningThreshold ) prune(); else { // Find minimum pruning threshold. if ( this.uniqueCount > 0 ) this.cube.numColors++; if ( this.quantizeError < this.cube.nextThreshold ) this.cube.nextThreshold = this.quantizeError; } }
/** * Update the contrast enhancement. Method getEnhanced(row, col, band) will apply this contrast enhancement before * returning values. * * @param ce */ public void setContrastEnhancement( ContrastEnhancement ce ) { contrast = ce; if ( contrast != null ) setGamma( contrast.gamma ); else setGamma( 1.0 ); }
Label(TextLayout pLayout, TextStyling pStyling, Font pFont, String pText, Point2D.Double pOrigin, RendererContext context){ mLayout = pLayout; mStyling = pStyling; mFont = pFont; mText = pText; mOrigin = pOrigin; double ox = mOrigin.x + context.uomCalculator.considerUOM( mStyling.displacementX, mStyling.uom ); double oy = mOrigin.y - context.uomCalculator.considerUOM( mStyling.displacementY, mStyling.uom ); double px = ox - ( mStyling.anchorPointX * mLayout.getBounds().getWidth() ); double py = oy + ( mStyling.anchorPointY * mLayout.getBounds().getHeight() ); mDrawPosition = new Point2D.Double(px,py); }
/** * Update the gamma value * * @param g * new gamma value */ public void setGamma( double g ) { if ( gamma != g ) gammaTable = createGammaTable( g ); gamma = g; }
private static int getType( boolean transparent, String format ) { if ( !isTransparentAndTransparencySupported( format, transparent ) ) { return TYPE_INT_RGB; } return transparent ? TYPE_INT_ARGB : TYPE_INT_RGB; }
void reduceImageColors( int maxColors ) { this.nextThreshold = 0; while ( this.numColors > maxColors ) { long pruningThreshold = this.nextThreshold; this.nextThreshold = this.root.quantizeError - 1; this.numColors = this.firstColor; this.root.reduce( pruningThreshold ); } }
/** * Construct a DiffusionFilter */ public DiffusionFilterOp() { setMatrix( diffusionMatrix ); }
int fillColorMap( byte colorMap[][], int index ) { // Traverse any children. if ( this.numChildren > 0 ) for ( int id = 0; id < MAX_CHILDREN; id++ ) if ( this.children[id] != null ) index = this.children[id].fillColorMap( colorMap, index ); if ( this.uniqueCount != 0 ) { // Colormap entry is defined by the mean color in this cube. colorMap[0][index] = (byte) ( this.totalRed / this.uniqueCount + 0.5 ); colorMap[1][index] = (byte) ( this.totalGreen / this.uniqueCount + 0.5 ); colorMap[2][index] = (byte) ( this.totalBlue / this.uniqueCount + 0.5 ); colorMap[3][index] = (byte) ( this.totalAlpha / this.uniqueCount + 0.5 ); this.colorIndex = index++; } return index; } }
void prune() { // Traverse any children. if ( this.numChildren > 0 ) for ( int id = 0; id < MAX_CHILDREN; id++ ) if ( this.children[id] != null ) this.children[id].prune(); // Merge color statistics into parent. this.parent.uniqueCount += this.uniqueCount; this.parent.totalRed += this.totalRed; this.parent.totalGreen += this.totalGreen; this.parent.totalBlue += this.totalBlue; this.parent.totalAlpha += this.totalAlpha; this.parent.children[this.id] = null; this.parent.numChildren--; this.cube.numNodes--; }
void findClosestColor( int red, int green, int blue, int alpha, ClosestColor closest ) { // Traverse any children. if ( this.numChildren > 0 ) for ( int id = 0; id < MAX_CHILDREN; id++ ) if ( this.children[id] != null ) this.children[id].findClosestColor( red, green, blue, alpha, closest ); if ( this.uniqueCount != 0 ) { // Determine if this color is "closest". int dr = ( this.cube.colorMap[0][this.colorIndex] & 0xff ) - red; int dg = ( this.cube.colorMap[1][this.colorIndex] & 0xff ) - green; int db = ( this.cube.colorMap[2][this.colorIndex] & 0xff ) - blue; int da = ( this.cube.colorMap[3][this.colorIndex] & 0xff ) - alpha; int distance = da * da + dr * dr + dg * dg + db * db; if ( distance < closest.distance ) { closest.distance = distance; closest.colorIndex = this.colorIndex; } } }
private void handleOutline( RasterStyling styling, AbstractRaster raster ) { // TODO cleanup outline stuff if ( styling.imageOutline != null ) { LOG.trace( "Rendering image outline..." ); Geometry geom = Raster2Feature.createPolygonGeometry( raster ); Java2DRenderer vectorRenderer = new Java2DRenderer( graphics ); @SuppressWarnings("unchecked") Pair<Styling, LinkedList<Geometry>> pair = (Pair) styling.imageOutline.evaluate( null, null ); Styling ls = pair.first; vectorRenderer.render( ls, geom ); LOG.trace( "Done rendering image outline." ); } }
public static RenderContext createInstance( RenderingInfo info, OutputStream outputStream ) { BufferedImage image = ImageUtils.prepareImage( info.getFormat(), info.getWidth(), info.getHeight(), info.getTransparent(), info.getBgColor() ); return createInstance( info, image, outputStream); }
/** * * @param d * raster data */ public RasterDataUtility( RasterData d ) { this.data = d; width = data.getColumns(); height = data.getRows(); bands = data.getBands(); BandType[] blist = d.getDataInfo().getBandInfo(); for ( int i = 0; i < blist.length; i++ ) if ( blist[i] == BandType.ALPHA ) alphaIndex = i; setGamma( 1.0 ); }
@Override protected void appendShape( GeneralPath result, Shape transformedShape ) { BasicStroke stroke = new BasicStroke( round( 2 * uomCalculator.considerUOM( halo.radius, uom ) ), CAP_BUTT, JOIN_ROUND ); Shape haloShape = stroke.createStrokedShape( transformedShape ); result.append( haloShape, false ); }