|
From: Tom H. <tur...@gm...> - 2005-10-17 19:54:30
|
Hi,
I understand that the GridCoverage stuff is in a state of change (and
the rendering stuff, also, for that matter) , but I was trying to
figure out, what the problem with the following snippet is. My data
has values from 0 - 100 and I wanted to ramp up to 40 by 10's.
Thanks in advance for any suggestions.
MapContext context =3D new DefaultMapContext();
=09=09ArcGridReader reader =3D new ArcGridReader(ShapefileRepository.class
=09=09=09=09.getResource("rastert_ictil_g1.txt"));
=09=09GridCoverage2D grid =3D (GridCoverage2D) reader.read(null);
=09=09ColorMap cm =3D builder.createColorMap(
=09=09=09=09new double[] { 0, 10, 20, 30, 40 }, new Color[] {
=09=09=09=09=09=09new Color(1, 1, 1, 1), Color.BLUE, Color.GREEN,
=09=09=09=09=09=09Color.YELLOW, Color.RED }, ColorMap.TYPE_RAMP);
=09=09symbolizer =3D builder.createRasterSymbolizer(cm, 1);
=09=09style =3D builder.createStyle("population", symbolizer);
=09=09context.addLayer(grid, style);
=09=09BufferedImage image =3D new BufferedImage(500, 500,
=09=09=09=09BufferedImage.TYPE_INT_ARGB);
=09=09LiteRenderer2 rend =3D new LiteRenderer2(context);
=09=09Graphics2D g2d =3D (Graphics2D) image.getGraphics();
=09=09rend.paint(g2d, new Rectangle(500, 500), context.getLayerBounds());
=09=09JLabel label =3D new JLabel();
=09=09label.setIcon(new ImageIcon(image));
=09=09label.setSize(500, 500);
=09=09label.setPreferredSize(new Dimension(500, 500));
=09=09JFrame frame =3D new JFrame();
=09=09frame.add(label, BorderLayout.CENTER);
=09=09frame.setSize(600, 600);
=09=09frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
=09=09frame.setVisible(true);
-Tom
|