00001
00002
00003
00004 package org.math.plot.plotObjects;
00005
00006 import java.awt.*;
00007 import java.io.*;
00008
00009 import javax.swing.*;
00010
00011 import org.math.plot.*;
00012 import org.math.plot.render.*;
00013
00014 public class RasterImage implements Plotable{
00015
00016 File source;
00017 Image img;
00018
00019 double[] xyzSW, xyzSE,xyzNW;
00020
00021 boolean visible = true;
00022 float alpha;
00023
00024 public RasterImage(File _source, float _alpha,double[] _xyzSW, double[] _xyzSE,double[] _xyzNW) {
00025 source = _source;
00026 img = Toolkit.getDefaultToolkit().getImage(source.getPath());
00027 xyzSW = _xyzSW;
00028 xyzSE = _xyzSE;
00029 xyzNW=_xyzNW;
00030 alpha = _alpha;
00031 }
00032
00033 public void plot(AbstractDrawer draw) {
00034 if (!visible) return;
00035
00036 draw.drawImage(img,alpha, xyzSW, xyzSE,xyzNW);
00037 }
00038
00039 public void setVisible(boolean v) {
00040 visible = v;
00041 }
00042
00043 public boolean getVisible() {
00044 return visible;
00045 }
00046
00047 public void setColor(Color c) {
00048 throw new IllegalArgumentException("method not available for this Object: PlotImage");
00049 }
00050
00051 public Color getColor() {
00052 return null;
00053 }
00054
00055 public static void main(String[] args) {
00056 Plot2DPanel p2 = new Plot2DPanel();
00057 for (int i = 0; i < 1; i++) {
00058 double[][] XYZ = new double[10][2];
00059 for (int j = 0; j < XYZ.length; j++) {
00060 XYZ[j][0] =Math.random();
00061 XYZ[j][1] = Math.random();
00062 }
00063 p2.addScatterPlot("toto" + i, XYZ);
00064 }
00065
00066 p2.addPlotable(new RasterImage(new File("test.gif"), 0.8f,new double[] {0.2,0.5},new double[] {1.2,0.8},new double[] {0.2,1.1}));
00067
00068 p2.setLegendOrientation(PlotPanel.SOUTH);
00069 new FrameView(p2).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
00070
00071
00072
00073 Plot3DPanel p = new Plot3DPanel();
00074 for (int i = 0; i < 1; i++) {
00075 double[][] XYZ = new double[10][3];
00076 for (int j = 0; j < XYZ.length; j++) {
00077 XYZ[j][0] = Math.random();
00078 XYZ[j][1] = Math.random();
00079 XYZ[j][2] = Math.random();
00080 }
00081 p.addScatterPlot("toto" + i, XYZ);
00082 }
00083
00084 p.addPlotable(new RasterImage(new File("test.gif"), 0.5f, new double[] {0.0,0.0,0.0},new double[] {1,0,0.0},new double[] {0.0,0,1}));
00085 p.addPlotable(new RasterImage(new File("test.gif"), 0.5f, new double[] {0.0,0.0,0.0},new double[] {0,1,0.0},new double[] {0,0.0,1}));
00086 p.addPlotable(new RasterImage(new File("test.gif"),0.5f, new double[] {0.0,0.0,0.0},new double[] {1,0,0},new double[] {0,1,0}));
00087
00088
00089
00090
00091 p.setLegendOrientation(PlotPanel.SOUTH);
00092 p.setPreferredSize(new Dimension(600,600));
00093 new FrameView(p).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
00094 }
00095
00096 }