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

📄 paralleldisplay.java

📁 一个java版本数据分析显示程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            float val = getValue(i, axisnum);            if ((val >= min) && (val < max))                count++;        }                return count;    }        /**     * Returns the number of brushed records in the given value range.     *     * @param axisnum The axis the given range is valid for.     * @param min The lower boundary of the range (>=).     * @param max The upper boundary of the range (<).     */    public int getNumBrushedInRange(int axisnum, float min, float max){        float count = 0;        for (int i=0; i<getNumRecords(); i++){            float val = getValue(i, axisnum);            if ((val >= min) && (val < max))                count += getBrushValue(i);        }                return (int)count;    }        /**     * Shortcut for preference access. For downwards compatibility.     */    public Color getRecordColor(){        return getColorPreference("recordColor");    }        /**     * Shortcut for preference access. For downwards compatibility.     */    public Color getBrushedColor(){        return getColorPreference("brushColor");    }        /**     * Sets the user interface delegate for the component.     */    public void setUI(ParallelDisplayUI ui){        super.setUI(ui);    }        /**     * Invalidates the component and causes a complete repaint.     */    public void invalidate(){        super.invalidate();        deepRepaint = true;    }        /**     * Swing method.     */    public void updateUI(){        try {            setUI((ParallelDisplayUI)UIManager.getUI(this));        }        catch (ClassCastException ccex){        }        invalidate();    }        /**     * Swing method.     */    public String getUIClassID(){        //System.out.println("retrieving classID");        return "org.mediavirus.parvis.gui.ParallelDisplayUI";    }        /**     * Invoked when the model has changed its state.     *     * @param e A ChangeEvent object     */    public void stateChanged(ChangeEvent e) {        repaint();    }        /**     * Returns the current offset (translation in axis units) for the axis.     *     * @param num The axis number.     *     * @return The offset value.     **/    public float getAxisOffset(int num){        if (axes != null){            return axes[num].offset;        }        else return 0;    }        /**     * Returns the current scale (visible region in axis units) for the axis.     *     * @param num The axis number.     *     * @return The scale value.     **/    public float getAxisScale(int num){        if (axes != null){            return axes[num].scale;        }        else return 0;    }        /**     * Returns a String label for a specific axis.     *     * @param num The axis number.     *     * @return A Human-readable label for the axis.     */        public String getAxisLabel(int num){        if (model != null){            String label = axes[num].label;            if (label != null) return label;            else return ("X" + axes[num].dimension);        }        else {            return null;        }    }        /**     * Sets the offset (translation in axis units) for the axis.     *     * @param axis The axis number.     * @param offset The offset value.     **/    public void setAxisOffset(int axis, float offset){        if (axes != null){            axes[axis].offset = offset;        }                repaint();    }        /**     * Sets the scale (visible region in axis units) for the axis.     *     * @param axis The axis number.     * @param scale The scale value.     **/    public void setAxisScale(int axis, float scale){        if (axes != null){            axes[axis].scale = scale;        }                repaint();    }        /**     * Configures (scales, translates) all axes to show all values between its     * minimum and its maximum on a maximum scale.     */    public void minMaxScale(){        for (int i=0; i<getNumAxes(); i++){            // initialize scaling of axis to show maximum detail            axes[i].offset = model.getMaxValue(axes[i].dimension);            axes[i].scale = model.getMinValue(axes[i].dimension) - axes[i].offset;        }                deepRepaint = true;        repaint();    }        /**     * Configures (scales, translates) all axes to show all values between zero     * and its maximum on a maximum scale.     */    public void zeroMaxScale(){        for (int i=0; i<getNumAxes(); i++){            // initialize scaling of axis to show maximum detail            axes[i].offset = model.getMaxValue(axes[i].dimension);            axes[i].scale = -1 * axes[i].offset;        }                deepRepaint = true;        repaint();    }        /**     * Configures (scales, translates) all axes to show values between zero     * (or the nagative minimum of all axes) and the maximum value of all axes     * on a maximum scale.     */    public void minMaxAbsScale(){        int i;                float absmax = Float.NEGATIVE_INFINITY;        float absmin = 0.0f;                for (i=0; i<getNumAxes(); i++){            // initialize scaling of axis to show maximum detail            float val = model.getMaxValue(axes[i].dimension);            if (val > absmax) absmax = val;            val =  model.getMinValue(axes[i].dimension);            if (val < absmin) absmin = val;        }                for (i=0; i<getNumAxes(); i++){            axes[i].offset = absmax;            axes[i].scale = absmin - absmax;        }                deepRepaint = true;        repaint();    }        private Vector progressListeners = new Vector();        public void addProgressListener(ProgressListener l){        progressListeners.add(l);    }        public void removeProgressListener(ProgressListener l){        progressListeners.remove(l);    }        private Vector brushListeners = new Vector();        public void addBrushListener(BrushListener l){        brushListeners.add(l);    }        public void removeBrushListener(BrushListener l){        brushListeners.remove(l);    }            public void fireProgressEvent(ProgressEvent e){        Vector list = (Vector)progressListeners.clone();        for (int i=0; i<list.size(); i++){            ProgressListener l = (ProgressListener)list.elementAt(i);            l.processProgressEvent(e);        }    }        public void fireBrushChanged(Brush b){        Vector list = (Vector)brushListeners.clone();        for (int i=0; i<list.size(); i++){            BrushListener l = (BrushListener)list.elementAt(i);            l.brushChanged(b);            l.brushModified(b);        }    }        public void fireBrushModified(Brush b){        Vector list = (Vector)brushListeners.clone();        for (int i=0; i<list.size(); i++){            BrushListener l = (BrushListener)list.elementAt(i);            l.brushModified(b);        }    }                Hashtable preferences = new Hashtable();        /** Holds value of property currentBrush. */    private Brush currentBrush;        /**     * Fills the preferences hashtable with initial default values.     */    public void setDefaultPreferences(){        preferences.put("brushRadius", new Float(0.2f));        preferences.put("softBrush", new Boolean(true));        preferences.put("hoverText", new Boolean(false));        preferences.put("hoverLine", new Boolean(false));        preferences.put("histogram", new Boolean(false));        preferences.put("histogramBins", new Integer(10));        preferences.put("histogramWidth", new Integer(HISTO_TOTALREC));        preferences.put("recordColor", Color.black);        preferences.put("brushColor", Color.black);    }        public void setFloatPreference(String key, float val){        Object obj = new Float(val);        preferences.put(key, obj);    }        public void setIntPreference(String key, int val){        Object obj = new Integer(val);        preferences.put(key, obj);    }        public void setBoolPreference(String key, boolean val){        Object obj = new Boolean(val);        preferences.put(key, obj);    }        public void setPreference(String key, Object val){        preferences.put(key, val);    }        public Object getPreference(String key){        return preferences.get(key);    }        public Color getColorPreference(String key){        Object obj = preferences.get(key);        if ((obj != null) && (obj instanceof Color)){            return (Color)obj;        }        // we should throw an exception here;        else return null;    }                public boolean getBoolPreference(String key){        Object obj = preferences.get(key);        if ((obj != null) && (obj instanceof Boolean)){            return ((Boolean)obj).booleanValue();        }        // we should throw an exception here;        else return false;    }        public float getFloatPreference(String key){        Object obj = preferences.get(key);        if ((obj != null) && (obj instanceof Float)){            return ((Float)obj).floatValue();        }        // we should throw an exception here;        else return 0.0f;    }        public int getIntPreference(String key){        Object obj = preferences.get(key);        if ((obj != null) && (obj instanceof Integer)){            return ((Integer)obj).intValue();        }        // we should throw an exception here;        else return 0;    }        /**     * Initializes the popup menu.     */    protected void setupPopup(){        int i;                String visible[] = new String[axes.length];        for (i = 0; i<axes.length; i++){            visible[i] = axes[i].label;        }                //String available[] = new String[model.getNumDimensions()];        //for (i = 0; i<available.length; i++){        //    available[i] = model.getDimensionLabel(i);        //}                popupMenu.setVisibleAxes(visible);        //popupMenu.setAvailableAxes(available);                if (cFrame != null) {            cFrame.updateAxes();        }    }        CorrelationFrame cFrame = null;        public void setCorrelationFrame(CorrelationFrame f){        cFrame = f;    }        /**     * Helper class: the popup menu.     */    class ParallelPopup extends JPopupMenu implements ActionListener{                JMenu addAxisMenu;        JMenu removeAxisMenu;                ParallelDisplay parent;                int targetRegion = 0;                ParallelPopup(ParallelDisplay parent){            super();                        this.parent = parent;                        addAxisMenu = new JMenu("Add axis");            removeAxisMenu = new JMenu("Remove axis");                        this.add(addAxisMenu);            this.add(removeAxisMenu);        }                void setVisibleAxes(String[] axes){            removeAxisMenu.removeAll();                        for (int i=0; i<axes.length; i++){                JMenuItem item = new JMenuItem();                item.setText(axes[i]);                item.setName("R" + i);                item.addActionListener(this);                                removeAxisMenu.add(item);            }        }                void setAvailableAxes(String[] axes){            addAxisMenu.removeAll();                        for (int i=0; i<axes.length; i++){                JMenuItem item = new JMenuItem();                item.setText(axes[i]);                item.setName("A" + i);                item.addActionListener(this);                                addAxisMenu.add(item);            }        }                public void actionPerformed(ActionEvent e){            System.out.println("Context menu action");            JMenuItem item = (JMenuItem)e.getSource();            if (item.getName().startsWith("R")){                int num = Integer.parseInt(item.getName().substring(1));                parent.removeAxis(num);            }            else if (item.getName().startsWith("A")){                int num = Integer.parseInt(item.getName().substring(1));                System.out.println("adding axis " + num);                parent.addAxis(num, targetRegion);            }        }                public void setTargetRegion(int region){            targetRegion = region;        }    }        }

⌨️ 快捷键说明

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