⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rpfcolortable.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
// **********************************************************************// // <copyright>// //  BBN Technologies//  10 Moulton Street//  Cambridge, MA 02138//  (617) 873-8000// //  Copyright (C) BBNT Solutions LLC. All rights reserved.// // </copyright>// **********************************************************************// // $Source: /cvs/distapps/openmap/src/openmap/com/bbn/openmap/layer/rpf/RpfColortable.java,v $// $RCSfile: RpfColortable.java,v $// $Revision: 1.3.2.1 $// $Date: 2004/10/14 18:27:14 $// $Author: dietrick $// // **********************************************************************/* * The meat of this code is based on source code provided by * The MITRE Corporation, through the browse application source * code.  Many thanks to Nancy Markuson who provided BBN with the * software, and Theron Tock, who wrote the software, and to * Daniel Scholten, who revised it - (c) 1994 The MITRE * Corporation for those parts, and used/distributed with permission. */package com.bbn.openmap.layer.rpf;import java.awt.Color;import java.io.IOException;import java.io.FileNotFoundException;import java.io.File;import com.bbn.openmap.io.BinaryBufferedFile;import com.bbn.openmap.io.BinaryFile;import com.bbn.openmap.io.FormatException;import com.bbn.openmap.util.Debug;/** * Set up the colors used in creating the images. They are created * from RGB value arrays read in from the RPF file. If the number of * colors that are allowed is less than 216, then the RpfColortable * looks inside the RpfFile and uses the color conversion tables * inside. There will still be 216 color indexes, but some of the * colors will be duplicates. */public class RpfColortable {    public final static int CADRG_COLORS = 216;    public final static int COLORS_216 = 0;    public final static int COLORS_32 = 1;    public final static int COLORS_16 = 2;    public final static int CIB_SPEC_CODE_ID = 3;    public final static int DEFAULT_OPAQUENESS = 255;    /**     * Color conversion table (to be filled) from within frame,     * colortable section. The colortable is always 216 entries long.     * If you want fewer colors, some of the entries are duplicated.     */    public int[] colorConvTable = new int[CADRG_COLORS];    /** Index to use a color conversion table, and if so, which one. */    protected int reducedColorTable = COLORS_216;    protected int numColors = 0;    protected boolean Cib = false;    protected int opaqueness = DEFAULT_OPAQUENESS;    /** The actual OMColors to use in the image construction. */    public Color[] colors = null;    /** Zone ID for these colors. */    public char zone;    /** Chart Series Code for these colors. */    public String seriesCode;    /**     * The index of the A.TOC file in the RpfTocHandler being used for     * the current colors.     */    protected int tocNumber = -1;    /**     * The index of the RpfEntry in the A.TOC file being used for the     * current colors.     */    protected int entryNumber = -1;    public RpfColortable() {        this(CADRG_COLORS, DEFAULT_OPAQUENESS, false);    }    public RpfColortable(int nColors) {        this(nColors, DEFAULT_OPAQUENESS, false);    }    public RpfColortable(int nColors, int opaque, boolean cib) {        setNumColors(nColors);        setOpaqueness(opaque);        setCib(cib);    }    /**     * Set the alpha values of the OMColors, which governs the     * transparency/opaqueness of the images.     *      * @param value index between 0-255 (0 is transparent, 255 is     *        opaque)     */    public void setOpaqueness(int value) {        opaqueness = value;        if (colors != null) {            for (int i = 0; i < colors.length; i++) {                Color tmp = colors[i];                colors[i] = new Color(tmp.getRed(), tmp.getGreen(), tmp.getBlue(), opaqueness);            }        }    }    public int getOpaqueness() {        return opaqueness;    }    /**     * Set the alpha values of the OMColors, which governs the     * transparency/opaqueness of the images. This method lets you set     * the value as a percentage between 0-100.     *      * @param percent index between 0-100 (0 is transparent, 100 is     *        opaque)     */    public void setOpaquePercent(int percent) {        setOpaqueness((int) ((float) (percent * 2.55)));    }    public int getOpaquePercent() {        return (int) ((float) opaqueness * 100.0 / 255.0);    }    public void setNumColors(int numColorsValue) {        numColors = numColorsValue;        if (numColors >= 216)            reducedColorTable = COLORS_216;        else if (numColors >= 32)            reducedColorTable = COLORS_32;        else            reducedColorTable = COLORS_16;    }    /** Returns the number of colors. */    public int getNumColors() {        return numColors;    }    /**     * Returns the color reduction index. These values correspond to     * the constants defined in this class.     */    public int getColorTableReduction() {        return reducedColorTable;    }    /**     * If this object is going to provide colors for CIB imagery, you     * have to let this object know that. Set this to true. It is     * false by default.     *      * @param value true if the colortable will be used for greyscale     *        images.     */    public void setCib(boolean value) {        Cib = value;    }    public boolean isCib() {        return Cib;    }    /**     * Should be set when a new colortable is read in, so that you can     * tell when you don't have to read a new one.     */    public void setATOCIndexes(int tocIndex, int entryIndex) {        tocNumber = tocIndex;        entryNumber = entryIndex;    }    /**     * Return true of the toc index and entry index are the same as     * what the colortable is currently holding.     */    public boolean isSameATOCIndexes(int tocIndex, int entryIndex) {        return (tocIndex == tocNumber && entryIndex == entryNumber);    }    /**     * Not really used, but someone might need them. Returns the A.TOC     * index number of the colors, to compare to see if a new     * colortable is needed.     */    public int getTocNumber() {        return tocNumber;    }    /**     * Not really used, but someone might need them. Returns the A.TOC     * entry number of the colors, to compare to see if a new     * colortable is needed.     */    public int getEntryNumber() {        return entryNumber;    }    /**     * The method to call to read in the colortable from within the     * RPF file. The method will use the input to determine where in     * the file to read from.     *      * @param binFile the file to read it in from.     * @param loc the RpfLocationRecord that tells you where the     *        sections are.     * @return an array of OMColors to use in images.     */    public Color[] parseColorLookUpTable(BinaryFile binFile,                                         RpfFileSections.RpfLocationRecord[] loc) {        if (Debug.debugging("rpfcolortable")) {            Debug.output("RpfColortable:  creating new colors for colortable.");        }        //  change this to the proper color structur        Color[] rgb = new Color[CADRG_COLORS]; /* DKS NEW: 216 */        int i, j;        long ncr;        int red, green, blue, alpha;        int numColorOffsetRecs; // uchar, # of color/gray offset                                // records */        int numColorConvOffsetRecs; //uchar        int offsetRecordLength = 17; //ushort        /* see frame.h */        ColorOffset[] colorOffset;        long colormapOffsetTableOffset; //uint        /* color converter subsection hdr */        long colorConvOffsetTableOffset; //uint        int colorConvOffsetRecl; // ushort        int colorConvRecl; // ushort        boolean foundLUT; /* found lut flag */        if (Debug.debugging("rpfdetail")) {            Debug.output("ENTER PARSE Colortable");        }        try {            /* Go find the color table: loc[0].id=LOC_CLUT */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -