Example usage for java.awt Color getRGB

List of usage examples for java.awt Color getRGB

Introduction

In this page you can find the example usage for java.awt Color getRGB.

Prototype

public int getRGB() 

Source Link

Document

Returns the RGB value representing the color in the default sRGB ColorModel .

Usage

From source file:ar.edu.uns.cs.vyglab.arq.rockar.gui.JFrameControlPanel.java

public void updateVisualizations() {
    // first, update piechart
    this.chart.setTitle(DataCenter.samplePath);
    this.pieChartDataset.clear();
    PiePlot plot = (PiePlot) chart.getPlot();
    for (Entry<Integer, Vector<Point>> entry : DataCenter.minerals.entrySet()) {
        if (entry.getValue().size() != 0) {
            this.pieChartDataset.setValue(DataCenter.names.get(entry.getKey()), entry.getValue().size());
            plot.setSectionPaint(DataCenter.names.get(entry.getKey()), DataCenter.colors.get(entry.getKey()));
        }/*from  www .  ja  v  a 2  s  .  c om*/
    }

    // then update overview, if exists
    //TODO fit jlabeloverview into jpanel
    if (DataCenter.pointsHorizontal != 0) {
        this.overview = new BufferedImage(DataCenter.pointsHorizontal, DataCenter.pointsVertical,
                BufferedImage.TYPE_INT_RGB);
        for (Entry<Point, Integer> entry : DataCenter.points.entrySet()) {
            int x = entry.getKey().x;
            int y = entry.getKey().y;
            Color c = DataCenter.colors.get(entry.getValue());
            this.overview.setRGB(x, y, c.getRGB());
        }
        scaled = this.overview.getScaledInstance(this.jPanelOverviewContent.getWidth(),
                this.jPanelOverviewContent.getHeight(), Image.SCALE_SMOOTH);
        //this.jLabelOverview.setIcon(new ImageIcon(this.overview));
        this.jLabelOverview.setIcon(new ImageIcon(scaled));
        this.jPanelOverviewContent.repaint();
    }

    // then update table information}
    this.jLabelMineralTableInformation
            .setText(DataCenter.langResource.getString("total_counted_table") + " " + DataCenter.points.size());
    int totalPoints = DataCenter.points.size();
    Set<Entry<Integer, Vector<Point>>> minerals = DataCenter.minerals.entrySet();
    for (Entry<Integer, Vector<Point>> item : minerals) {
        int mineral = item.getKey();
        for (int i = 0; i < this.jTableMineralsModel.getRowCount(); i++) {
            if (mineral == (Integer) this.jTableMineralsModel.getValueAt(i, 0)) {
                this.jTableMineralsModel.setValueAt(item.getValue().size(), i, 3);
                float countLocal = item.getValue().size();
                float total = totalPoints;
                float percent = (countLocal * (float) 100) / total;
                String s = String.format("%.2f", percent);
                this.jTableMineralsModel.setValueAt(s + "%", i, 4);
                break;
            }
        }
    }

    // update main view
    DataCenter.jframeSetter.getjLabelImage().repaint();
    /*
     * Set<Entry<Point, Integer>> points = DataCenter.points.entrySet();
    for( Entry<Point, Integer> item : points) {
     */
}

From source file:org.kurento.test.base.BrowserTest.java

public String ocr(BufferedImage imgBuff) {
    String parsedOut = null;//from   w  ww .  ja  v  a 2 s . c om

    try {
        // Color image to pure black and white
        for (int x = 0; x < imgBuff.getWidth(); x++) {
            for (int y = 0; y < imgBuff.getHeight(); y++) {
                Color color = new Color(imgBuff.getRGB(x, y));
                int red = color.getRed();
                int green = color.getBlue();
                int blue = color.getGreen();
                if (red + green + blue > OCR_COLOR_THRESHOLD) {
                    red = green = blue = 0; // Black
                } else {
                    red = green = blue = 255; // White
                }
                Color col = new Color(red, green, blue);
                imgBuff.setRGB(x, y, col.getRGB());
            }
        }

        // OCR recognition
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ImageIO.write(imgBuff, "png", baos);
        byte[] imageBytes = baos.toByteArray();

        TessBaseAPI api = new TessBaseAPI();
        api.Init(null, "eng");
        ByteBuffer imgBB = ByteBuffer.wrap(imageBytes);

        PIX image = pixReadMem(imgBB, imageBytes.length);
        api.SetImage(image);

        // Get OCR result
        BytePointer outText = api.GetUTF8Text();

        // Destroy used object and release memory
        api.End();
        api.close();
        outText.deallocate();
        pixDestroy(image);

        // OCR corrections
        parsedOut = outText.getString().replaceAll("l", "1").replaceAll("Z", "2").replaceAll("O", "0")
                .replaceAll("B", "8").replaceAll("G", "6").replaceAll("S", "8").replaceAll("'", "")
                .replaceAll("", "").replaceAll("\\.", ":").replaceAll("E", "8").replaceAll("o", "0")
                .replaceAll("", "0").replaceAll("?", "6").replaceAll("", "5").replaceAll("I", "1")
                .replaceAll("T", "7").replaceAll("", "").replaceAll("U", "0").replaceAll("D", "0");
        if (parsedOut.length() > 7) {
            parsedOut = parsedOut.substring(0, 7) + ":" + parsedOut.substring(8, parsedOut.length());
        }
        parsedOut = parsedOut.replaceAll("::", ":");

        // Remove last part (number of frames)
        int iSpace = parsedOut.lastIndexOf(" ");
        if (iSpace != -1) {
            parsedOut = parsedOut.substring(0, iSpace);
        }
    } catch (IOException e) {
        log.warn("IOException in OCR", e);
    }
    return parsedOut;
}

From source file:com.t3.model.MacroButtonProperties.java

/**
 * Returns the font color of this button as an HTML string. It might be one of the 16 colors defined by the W3C as a
 * standard HTML color (see <code>COLOR_MAP_HTML</code> for a list), but if it's not then the color is converted to
 * CSS format <b>#FF00FF</b> format and that string is returned.
 * //  w ww.java  2  s .  c  o m
 * @return
 */
public String getFontColorAsHtml() {
    Color c = null;
    String font = getFontColorKey();
    if (T3Util.isHtmlColor(font)) {
        return font;
    }
    c = T3Util.getColor(font);
    if (c != null) {
        return "#" + Integer.toHexString(c.getRGB()).substring(2);
    }
    return "black";
}

From source file:org.geopublishing.atlasStyler.swing.PolygonSymbolEditGUI.java

/**
 * This method initializes jButton//from www.j  a v  a2s  . co m
 * 
 * @return javax.swing.JButton
 */
private ColorButton getJButtonStrokeColor() {
    if (jButtonStrokeColor == null) {
        jButtonStrokeColor = new ColorButton();

        jButtonStrokeColor.setAction(new AbstractAction() {

            @Override
            public void actionPerformed(ActionEvent e) {

                Fill fill = symbolizer.getFill();

                Color color = null;
                if (fill != null && fill.getColor() != null) {
                    String substring = fill.getColor().toString();
                    color = Color.decode(substring);
                }

                Color newColor = AVSwingUtil.showColorChooser(PolygonSymbolEditGUI.this,
                        AtlasStylerVector.R("Stroke.ColorChooserDialog.Title"), color);

                if (newColor != null) {
                    String rgb = Integer.toHexString(newColor.getRGB());
                    rgb = "#" + rgb.substring(2, rgb.length());
                    symbolizer.getStroke().setColor(ASUtil.ff2.literal(rgb));

                    PolygonSymbolEditGUI.this.firePropertyChange(PROPERTY_UPDATED, null, null);

                    jButtonStrokeColor.setColor(newColor);

                }

            }

        });

        Stroke s = symbolizer.getStroke();
        if (s != null) {
            jButtonStrokeColor.setColor(StylingUtil.getColorFromExpression(s.getColor()));
        } else {
            jButtonStrokeColor.setEnabled(false);
        }

    }
    return jButtonStrokeColor;
}

From source file:org.kalypsodeegree_impl.graphics.displayelements.RasterDisplayElement_Impl.java

private BufferedImage getTiledImage(final int screenWidth, final int screenHeight, final double[][] values,
        final double[][] slopes) {
    final BufferedImage img = new BufferedImage(screenWidth, screenHeight, BufferedImage.TYPE_INT_ARGB);

    for (int y = 0; y < screenHeight; y++) {
        for (int x = 0; x < screenWidth; x++) {
            final double value = values[y + 1][x + 1];
            if (!Double.isNaN(value)) {
                final Color color = getColor(value);
                if (color != null) {
                    final double slope = slopes == null ? Double.NaN : slopes[y + 1][x + 1];
                    if (Double.isNaN(slope))
                        img.setRGB(x, y, color.getRGB());
                    else {
                        final Color shadedColor = shadeColor(color, slope);
                        img.setRGB(x, y, shadedColor.getRGB());
                    }/*  ww  w.  j  av  a2s.c om*/
                }
            }
        }
    }
    return img;
}

From source file:org.geopublishing.atlasStyler.swing.PolygonSymbolEditGUI.java

/**
 * This method initializes jComboBox//from   w ww  .  j  a  v a 2 s.  c o m
 * 
 * @return javax.swing.JComboBox
 */
private ColorButton getJButtonFillColor() {
    if (jButtonFillColor == null) {
        jButtonFillColor = new ColorButton();

        jButtonFillColor.setAction(new AbstractAction() {

            @Override
            public void actionPerformed(ActionEvent e) {

                Fill fill = symbolizer.getFill();

                Color color = null;
                if (fill != null && fill.getColor() != null) {
                    String substring = fill.getColor().toString();
                    color = Color.decode(substring);
                }
                // Color newColor = JColorChooser.showDialog(
                // PolygonSymbolEditGUI.this, "Choose fill color",
                // color); // i8nAC
                Color newColor = AVSwingUtil.showColorChooser(PolygonSymbolEditGUI.this,
                        AtlasStylerVector.R("Fill.ColorChooserDialog.Title"), color);

                if (newColor != null && newColor != color) {
                    String rgb = Integer.toHexString(newColor.getRGB());
                    rgb = "#" + rgb.substring(2, rgb.length());
                    fill.setColor(ASUtil.ff2.literal(rgb));

                    PolygonSymbolEditGUI.this.firePropertyChange(PROPERTY_UPDATED, null, null);

                    jButtonFillColor.setColor(newColor);

                }

            }

        });

        Fill f = symbolizer.getFill();
        if (f != null) {
            jButtonFillColor.setColor(StylingUtil.getColorFromExpression(f.getColor()));
        } else {
            jButtonFillColor.setColor((Color) null);
            jPanelFill.setEnabled(false);
        }
    }
    return jButtonFillColor;
}

From source file:net.sf.firemox.Magic.java

public void actionPerformed(ActionEvent e) {
    final String command = e.getActionCommand();
    final Object obj = e.getSource();
    if (obj == sendButton) {
        if (sendTxt.getText().length() != 0) {
            MChat.getInstance().sendMessage(sendTxt.getText() + "\n");
            sendTxt.setText("");
        }/*from   ww  w  .j  a  va 2  s. c o  m*/
    } else if (command != null && command.startsWith("border-")) {
        for (int i = cardBorderMenu.getComponentCount(); i-- > 0;) {
            ((JRadioButtonMenuItem) cardBorderMenu.getComponent(i)).setSelected(false);
        }
        ((JRadioButtonMenuItem) obj).setSelected(true);
        CardFactory.updateColor(command.substring("border-".length()));
        CardFactory.updateAllCardsUI();
        magicForm.repaint();
    } else if ("menu_help_mailing".equals(command)) {
        try {
            WebBrowser.launchBrowser(
                    "http://lists.sourceforge.net/lists/listinfo/" + IdConst.PROJECT_NAME + "-user");
        } catch (Exception e1) {
            JOptionPane.showOptionDialog(this, LanguageManager.getString("error") + " : " + e1.getMessage(),
                    LanguageManager.getString("web-pb"), JOptionPane.OK_OPTION, JOptionPane.INFORMATION_MESSAGE,
                    UIHelper.getIcon("wiz_update_error.gif"), null, null);
        }
    } else if ("menu_options_settings".equals(command)) {
        // Setting panel
        final Wizard settingsPanel = new Settings();
        settingsPanel.setVisible(true);
    } else if ("menu_help_check-update".equals(command)) {
        VersionChecker.checkVersion(this);
    } else if ("menu_game_new_client".equals(command)) {
        new net.sf.firemox.ui.wizard.Client().setVisible(true);
    } else if ("menu_game_new_server".equals(command)) {
        new net.sf.firemox.ui.wizard.Server().setVisible(true);
    } else if ("menu_tools_log".equals(command)) {
        new net.sf.firemox.ui.wizard.Log().setVisible(true);
    } else if ("menu_tools_featurerequest".equals(command)) {
        new Feature().setVisible(true);
    } else if ("menu_tools_bugreport".equals(command)) {
        new Bug().setVisible(true);
    } else if ("menu_game_skip".equals(command)) {
        if (ConnectionManager.isConnected() && skipButton.isEnabled() && StackManager.idHandedPlayer == 0) {
            StackManager.noReplayToken.take();
            try {
                manualSkip();
            } catch (Throwable t) {
                t.printStackTrace();
            } finally {
                StackManager.noReplayToken.release();
            }
        }
    } else if ("menu_game_disconnect".equals(command)) {
        ConnectionManager.closeConnexions();
    } else if ("menu_tools_jdb".equals(command)) {
        DeckBuilder.loadFromMagic();
    } else if ("menu_game_exit".equals(command)) {
        exitForm(null);
    } else if (obj == autoManaMenu) {
        /*
         * invoked you click directly on the "auto-mana option" of the menu
         * "options". The opponent has to know that we are in "auto colorless mana
         * use", since player will no longer click on the mana icon to define
         * which colored mana active player has used as colorless mana, then the
         * opponent have not to wait for active player choice, but apply the same
         * Algorithm calculating which colored manas are used as colorless manas.
         * This information is not sent immediately, but will be sent with the
         * next action of active player.
         */
        MCommonVars.autoMana = autoManaMenu.isSelected();
    } else if (obj == autoPlayMenu) {
        /*
         * invoked you click directly on the "auto-play option" of the menu
         * "options".
         */
        MCommonVars.autoStack = autoPlayMenu.isSelected();
    } else if ("menu_tools_jcb".equals(command)) {
        // TODO cardBuilderMenu -> not yet implemented
        Log.info("cardBuilderMenu -> not yet implemented");
    } else if ("menu_game_proxy".equals(command)) {
        new ProxyConfiguration().setVisible(true);
    } else if ("menu_help_help".equals(command)) {
        /*
         * Invoked you click directly on youLabel. Opponent will receive this
         * information.
         */
        try {
            WebBrowser.launchBrowser("http://prdownloads.sourceforge.net/" + IdConst.PROJECT_NAME
                    + "/7e_rulebook_EN.pdf?download");
        } catch (Exception e1) {
            JOptionPane.showOptionDialog(this, LanguageManager.getString("error") + " : " + e1.getMessage(),
                    LanguageManager.getString("web-pb"), JOptionPane.OK_OPTION, JOptionPane.INFORMATION_MESSAGE,
                    UIHelper.getIcon("wiz_update_error.gif"), null, null);
        }
    } else if ("menu_help_about".equals(command)) {
        new About(this).setVisible(true);
    } else if ("menu_help_about.tbs".equals(command)) {
        new AboutMdb(this).setVisible(true);
    } else if (obj == reverseArtCheck || obj == reverseSideCheck) {
        Configuration.setProperty("reverseArt", reverseArtCheck.isSelected());
        Configuration.setProperty("reverseSide", reverseSideCheck.isSelected());
        ZoneManager.updateReversed();
        StackManager.PLAYERS[1].updateReversed();
        repaint();
        SwingUtilities.invokeLater(SkinLF.REFRESH_RUNNER);
    } else if (obj == soundMenu) {
        Configuration.setProperty("sound", soundMenu.isSelected());
        soundMenu.setIcon(
                soundMenu.isSelected() ? UIHelper.getIcon("sound.gif") : UIHelper.getIcon("soundoff.gif"));
    } else if ("menu_lf_randomAngle".equals(command)) {
        Configuration.setProperty("randomAngle", ((AbstractButton) e.getSource()).isSelected());
        CardFactory.updateAllCardsUI();
    } else if ("menu_lf_powerToughnessColor".equals(command)) {
        final Color powerToughnessColor = JColorChooser.showDialog(this,
                LanguageManager.getString("menu_lf_powerToughnessColor"), CardFactory.powerToughnessColor);
        if (powerToughnessColor != null) {
            Configuration.setProperty("powerToughnessColor", powerToughnessColor.getRGB());
            CardFactory.updateColor(null);
            repaint();
        }
    } else if (obj == initialdelayMenu) {
        // TODO factor this code with the one of Magic.class
        final ToolTipManager toolTipManager = ToolTipManager.sharedInstance();
        new InputNumber(LanguageManager.getString("initialdelay"),
                LanguageManager.getString("initialdelay.tooltip"), 0, Integer.MAX_VALUE,
                toolTipManager.getInitialDelay()).setVisible(true);
        if (Wizard.optionAnswer == JOptionPane.YES_OPTION) {
            toolTipManager.setEnabled(Wizard.indexAnswer != 0);
            toolTipManager.setInitialDelay(Wizard.indexAnswer);
            initialdelayMenu.setText(LanguageManager.getString("initialdelay")
                    + (toolTipManager.isEnabled() ? " : " + Wizard.indexAnswer + " ms" : "(disabled)"));
            Configuration.setProperty("initialdelay", Wizard.indexAnswer);
        }
    } else if (obj == dismissdelayMenu) {
        // TODO factor this code with the one of Magic.class
        final ToolTipManager toolTipManager = ToolTipManager.sharedInstance();
        new InputNumber(LanguageManager.getString("dismissdelay"),
                LanguageManager.getString("dismissdelay.tooltip"), 0, Integer.MAX_VALUE,
                toolTipManager.getDismissDelay()).setVisible(true);
        if (Wizard.optionAnswer == JOptionPane.YES_OPTION) {
            toolTipManager.setDismissDelay(Wizard.indexAnswer);
            Configuration.setProperty("dismissdelay", Wizard.indexAnswer);
            dismissdelayMenu.setText(LanguageManager.getString("dismissdelay") + Wizard.indexAnswer + " ms");
        }
    }

}

From source file:edu.umn.cs.spatialHadoop.operations.PyramidPlot.java

/**
 * Plot a file to a set of images in different zoom levels using a MapReduce
 * program.//from  w ww. ja v  a  2 s  .c  om
 * @param <S> type of shapes stored in file
 * @param inFile - Path to the input file(s)
 * @param outFile - Path to the output file (image)
 * @param shape - A sample object to be used for parsing input file
 * @param tileWidth - With of each tile 
 * @param tileHeight - Height of each tile
 * @param vflip - Set to <code>true</code> to file the whole image vertically
 * @param color - Color used to draw single shapes
 * @param numLevels - Number of zoom levels to plot
 * @throws IOException
 */
private static <S extends Shape> RunningJob plotMapReduce(Path inFile, Path outFile, OperationsParams params)
        throws IOException {
    Color color = params.getColor("color", Color.BLACK);

    String hdfDataset = (String) params.get("dataset");
    Shape shape = hdfDataset != null ? new NASARectangle() : params.getShape("shape");
    Shape plotRange = params.getShape("rect");

    boolean background = params.is("background");

    JobConf job = new JobConf(params, PyramidPlot.class);
    job.setJobName("PlotPyramid");

    String partition = job.get("partition", "space").toLowerCase();
    if (partition.equals("space")) {
        job.setMapperClass(SpacePartitionMap.class);
        job.setReducerClass(SpacePartitionReduce.class);
        job.setMapOutputKeyClass(TileIndex.class);
        job.setMapOutputValueClass(shape.getClass());
        job.setInputFormat(ShapeInputFormat.class);
    } else {
        job.setMapperClass(DataPartitionMap.class);
        job.setReducerClass(DataPartitionReduce.class);
        job.setMapOutputKeyClass(TileIndex.class);
        job.setMapOutputValueClass(ImageWritable.class);
        job.setInputFormat(ShapeArrayInputFormat.class);
    }

    job.setInt("color", color.getRGB());
    ClusterStatus clusterStatus = new JobClient(job).getClusterStatus();
    job.setNumMapTasks(clusterStatus.getMaxMapTasks() * 5);
    job.setNumReduceTasks(Math.max(1, clusterStatus.getMaxReduceTasks()));

    if (shape instanceof Point && job.getBoolean("sample", false)) {
        // Enable adaptive sampling
        int imageWidthRoot = job.getInt("tilewidth", 256);
        int imageHeightRoot = job.getInt("tileheight", 256);
        long recordCount = FileMBR.fileMBR(inFile, params).recordCount;
        float sampleRatio = params.getFloat(GeometricPlot.AdaptiveSampleFactor, 1.0f) * imageWidthRoot
                * imageHeightRoot / recordCount;
        job.setFloat(GeometricPlot.AdaptiveSampleRatio, sampleRatio);
    }

    Rectangle fileMBR;
    if (hdfDataset != null) {
        // Input is HDF
        job.set(HDFRecordReader.DatasetName, hdfDataset);
        job.setBoolean(HDFRecordReader.SkipFillValue, true);
        job.setClass("shape", NASARectangle.class, Shape.class);
        // Determine the range of values by opening one of the HDF files
        Aggregate.MinMax minMax = Aggregate.aggregate(new Path[] { inFile }, params);
        job.setInt(MinValue, minMax.minValue);
        job.setInt(MaxValue, minMax.maxValue);
        //fileMBR = new Rectangle(-180, -90, 180, 90);
        fileMBR = plotRange != null ? plotRange.getMBR() : new Rectangle(-180, -140, 180, 169);
        //      job.setClass(HDFRecordReader.ProjectorClass, MercatorProjector.class,
        //          GeoProjector.class);
    } else {
        fileMBR = FileMBR.fileMBR(inFile, params);
    }

    boolean keepAspectRatio = params.is("keep-ratio", true);
    if (keepAspectRatio) {
        // Expand input file to a rectangle for compatibility with the pyramid
        // structure
        if (fileMBR.getWidth() > fileMBR.getHeight()) {
            fileMBR.y1 -= (fileMBR.getWidth() - fileMBR.getHeight()) / 2;
            fileMBR.y2 = fileMBR.y1 + fileMBR.getWidth();
        } else {
            fileMBR.x1 -= (fileMBR.getHeight() - fileMBR.getWidth() / 2);
            fileMBR.x2 = fileMBR.x1 + fileMBR.getHeight();
        }
    }

    SpatialSite.setRectangle(job, InputMBR, fileMBR);

    // Set input and output
    ShapeInputFormat.addInputPath(job, inFile);
    if (plotRange != null) {
        job.setClass(SpatialSite.FilterClass, RangeFilter.class, BlockFilter.class);
    }

    job.setOutputFormat(PyramidOutputFormat.class);
    TextOutputFormat.setOutputPath(job, outFile);
    job.setOutputCommitter(PlotPyramidOutputCommitter.class);

    if (background) {
        JobClient jc = new JobClient(job);
        return lastSubmittedJob = jc.submitJob(job);
    } else {
        return lastSubmittedJob = JobClient.runJob(job);
    }

}

From source file:ome.services.blitz.impl.OmeroMetadata.java

@Override
public Integer getChannelColor(int imageIndex, int channelIndex) {
    Channel o = getChannel(imageIndex, channelIndex);
    if (o == null) {
        return null;
    }/* w  w  w. java 2  s. c o m*/
    try {
        Color color = new Color(fromRType(o.getRed()), fromRType(o.getGreen()), fromRType(o.getBlue()),
                fromRType(o.getAlpha()));
        int argb = color.getRGB();
        // ARGB --> RGBA
        return (argb << 8) | (argb >>> (32 - 8));
    } catch (NullPointerException e) {
        return null;
    }
}

From source file:edu.umn.cs.spatialHadoop.operations.Plot.java

public static void drawShape(Graphics2D graphics, Shape s, Rectangle fileMbr, int imageWidth, int imageHeight,
        double scale) {
    if (s instanceof NASAPoint) {
        final int MinValue = 7500;
        final int MaxValue = 16000;
        NASAPoint pt = (NASAPoint) s;//from  w  w  w .  jav a 2 s  .  c om
        int x = (int) ((pt.x - fileMbr.x1) * imageWidth / (fileMbr.x2 - fileMbr.x1));
        int y = (int) ((pt.y - fileMbr.y1) * imageHeight / (fileMbr.y2 - fileMbr.y1));
        int value = pt.value;

        if (value < min_value && value > 1000)
            min_value = value;
        if (value > max_value)
            max_value = value;

        if (value > 0 && x >= 0 && x < imageWidth && y >= 0 && y < imageHeight) {
            Color color;
            if (value < MinValue) {
                color = Color.BLACK;
            } else if (value < MaxValue) {
                float ratio = 0.78f - 0.78f * (value - MinValue) / (MaxValue - MinValue);
                color = Color.getHSBColor(ratio, 0.5f, 1.0f);
            } else {
                color = Color.WHITE;
            }
            graphics.setColor(color);
            graphics.fillRect(x, y, 1, 1);
        }
    } else if (s instanceof Point) {
        Point pt = (Point) s;
        int x = (int) ((pt.x - fileMbr.x1) * imageWidth / (fileMbr.x2 - fileMbr.x1));
        int y = (int) ((pt.y - fileMbr.y1) * imageHeight / (fileMbr.y2 - fileMbr.y1));

        if (x >= 0 && x < imageWidth && y >= 0 && y < imageHeight)
            graphics.fillRect(x, y, 1, 1);
    } else if (s instanceof Rectangle) {
        Rectangle r = (Rectangle) s;
        int s_x1 = (int) ((r.x1 - fileMbr.x1) * imageWidth / (fileMbr.x2 - fileMbr.x1));
        int s_y1 = (int) ((r.y1 - fileMbr.y1) * imageHeight / (fileMbr.y2 - fileMbr.y1));
        int s_x2 = (int) (((r.x2) - fileMbr.x1) * imageWidth / (fileMbr.x2 - fileMbr.x1));
        int s_y2 = (int) (((r.y2) - fileMbr.y1) * imageHeight / (fileMbr.y2 - fileMbr.y1));
        graphics.drawRect(s_x1, s_y1, s_x2 - s_x1 + 1, s_y2 - s_y1 + 1);
    } else if (s instanceof OGCShape) {
        OGCShape ogc_shape = (OGCShape) s;
        OGCGeometry geom = ogc_shape.geom;
        Color shape_color = graphics.getColor();
        if (geom instanceof OGCGeometryCollection) {
            OGCGeometryCollection geom_coll = (OGCGeometryCollection) geom;
            for (int i = 0; i < geom_coll.numGeometries(); i++) {
                OGCGeometry sub_geom = geom_coll.geometryN(i);
                // Recursive call to draw each geometry
                drawShape(graphics, new OGCShape(sub_geom), fileMbr, imageWidth, imageHeight, scale);
            }
        } else if (geom.getEsriGeometry() instanceof MultiPath) {
            MultiPath path = (MultiPath) geom.getEsriGeometry();
            double sub_geom_alpha = path.calculateLength2D() * scale;
            int color_alpha = sub_geom_alpha > 1.0 ? 255 : (int) Math.round(sub_geom_alpha * 255);

            if (color_alpha == 0)
                return;

            int[] xpoints = new int[path.getPointCount()];
            int[] ypoints = new int[path.getPointCount()];

            for (int i = 0; i < path.getPointCount(); i++) {
                double px = path.getPoint(i).getX();
                double py = path.getPoint(i).getY();

                // Transform a point in the polygon to image coordinates
                xpoints[i] = (int) Math.round((px - fileMbr.x1) * imageWidth / (fileMbr.x2 - fileMbr.x1));
                ypoints[i] = (int) Math.round((py - fileMbr.y1) * imageHeight / (fileMbr.y2 - fileMbr.y1));
            }

            // Draw the polygon
            graphics.setColor(new Color((shape_color.getRGB() & 0x00FFFFFF) | (color_alpha << 24), true));
            if (path instanceof Polygon)
                graphics.drawPolygon(xpoints, ypoints, path.getPointCount());
            else if (path instanceof Polyline)
                graphics.drawPolyline(xpoints, ypoints, path.getPointCount());
        }
    } else if (s instanceof JTSShape) {
        JTSShape jts_shape = (JTSShape) s;
        Geometry geom = jts_shape.geom;
        Color shape_color = graphics.getColor();

        drawJTSShape(graphics, geom, fileMbr, imageWidth, imageHeight, scale, shape_color);
    } else {
        LOG.warn("Cannot draw a shape of type: " + s.getClass());
        Rectangle r = s.getMBR();
        int s_x1 = (int) ((r.x1 - fileMbr.x1) * imageWidth / (fileMbr.x2 - fileMbr.x1));
        int s_y1 = (int) ((r.y1 - fileMbr.y1) * imageHeight / (fileMbr.y2 - fileMbr.y1));
        int s_x2 = (int) (((r.x2) - fileMbr.x1) * imageWidth / (fileMbr.x2 - fileMbr.x1));
        int s_y2 = (int) (((r.y2) - fileMbr.y1) * imageHeight / (fileMbr.y2 - fileMbr.y1));
        if (s_x1 >= 0 && s_x1 < imageWidth && s_y1 >= 0 && s_y1 < imageHeight)
            graphics.drawRect(s_x1, s_y1, s_x2 - s_x1 + 1, s_y2 - s_y1 + 1);
    }
}