コード例 #1
0
ファイル: Viewer3D.java プロジェクト: psava/cwp12
 public void saveView(String filename) {
   BoundingSphere bs = _ipg.getBoundingSphere(true);
   Vector3 tvec = _view.getTranslate();
   try {
     FileWriter fw = new FileWriter(filename);
     PrintWriter out = new PrintWriter(fw);
     out.println(bs.getRadius());
     Point3 center = bs.getCenter();
     out.printf("%f %f %f \n", center.x, center.y, center.z);
     out.println(_view.getAzimuth());
     out.println(_view.getElevation());
     out.println(_view.getScale());
     out.printf("%f %f %f \n", tvec.x, tvec.y, tvec.z);
     Iterator<ImagePanel> itr = _ipg.getImagePanels();
     while (itr.hasNext()) {
       ImagePanel ip = itr.next();
       AxisAlignedFrame aaf = ip.getFrame();
       Point3 min = aaf.getCornerMin();
       Point3 max = aaf.getCornerMax();
       out.printf("%f %f %f %f %f %f\n", min.x, min.y, min.z, max.x, max.y, max.z);
     }
     out.println(_pmax);
     out.println(_color.getCode());
     out.close();
   } catch (Exception e) {
     System.out.println(e);
   }
 }
コード例 #2
0
ファイル: IvusFrame.java プロジェクト: BKJackson/idh
 private static void addSlices(World world, Float3 f) {
   int nx = f.getN3();
   int ny = f.getN2();
   int nz = f.getN1();
   double dx = 1.0;
   double dy = 1.0;
   double dz = 1.0;
   double fx = 0.0;
   double fy = 0.0;
   double fz = 0.0;
   double lx = fx + (nx - 1) * dx;
   double ly = fy + (ny - 1) * dy;
   double lz = fz + (nz - 1) * dz;
   Sampling sx = new Sampling(nx, dx, fx);
   Sampling sy = new Sampling(ny, dy, fy);
   Sampling sz = new Sampling(nz, dz, fz);
   Point3 qmin = new Point3(fx, fy, fz);
   Point3 qmax = new Point3(lx, ly, lz);
   Axis[] axes = new Axis[] {Axis.X, Axis.Y, Axis.Z};
   for (int iaxis = 0; iaxis < axes.length; ++iaxis) {
     AxisAlignedQuad aaq = new AxisAlignedQuad(axes[iaxis], qmin, qmax);
     AxisAlignedFrame aaf = aaq.getFrame();
     ImagePanel ip = new ImagePanel(sz, sy, sx, f);
     ip.setColorModel(ColorMap.GRAY);
     System.out.println("clip min=" + ip.getClipMin() + " max=" + ip.getClipMax());
     aaf.addChild(ip);
     world.addChild(aaq);
   }
 }
コード例 #3
0
ファイル: Viewer3D.java プロジェクト: psava/cwp12
  public void loadView(String filename) {
    Point3 point;
    Vector3 tvec;
    double radius;
    double azimuth;
    double elevation;
    double scale;
    double x, y, z;
    double vx, vy, vz;

    try {
      if (_ipg == null) throw new Exception("Must load a cube first!");
      Scanner s = new Scanner(new File(filename));
      radius = s.nextDouble();
      x = s.nextDouble();
      y = s.nextDouble();
      z = s.nextDouble();
      point = new Point3(x, y, z);
      azimuth = s.nextDouble();
      elevation = s.nextDouble();
      scale = s.nextDouble();
      vx = s.nextDouble();
      vy = s.nextDouble();
      vz = s.nextDouble();
      tvec = new Vector3(vx, vy, vz);
      Iterator<ImagePanel> itr = _ipg.getImagePanels();
      while (itr.hasNext()) {
        ImagePanel ip = itr.next();
        AxisAlignedFrame aaf = ip.getFrame();
        double lx = s.nextDouble();
        double ly = s.nextDouble();
        double lz = s.nextDouble();
        double mx = s.nextDouble();
        double my = s.nextDouble();
        double mz = s.nextDouble();

        Point3 min = new Point3(lx, ly, lz);
        Point3 max = new Point3(mx, my, mz);
        aaf.setCorners(min, max);
      }
      _pmax = s.nextFloat();
      int code = s.nextInt();
      _color = ColorList.getMatch(code);
      setColorMap();
      _view.setWorldSphere(new BoundingSphere(point, radius));
      _view.setTranslate(tvec);
      _view.setAzimuth(azimuth);
      _view.setElevation(elevation);
      _view.setScale(scale);
      _ipg.setPercentiles(_pmin, _pmax);

    } catch (Exception e) {
      System.out.println("Failed to load view point!");
      System.out.println(e);
    }
  }
コード例 #4
0
ファイル: DisplayImage.java プロジェクト: milianw/scivi
 public void setImage(BufferedImage image) {
   m_panel.setImage(image);
   setSize(image.getWidth(), image.getHeight());
   m_panel.setSize(image.getWidth(), image.getHeight());
   m_panel.repaint();
   update(getGraphics());
   if (!isVisible()) {
     setVisible(true);
   }
   System.out.println("update image");
 }
コード例 #5
0
ファイル: Viewer3D.java プロジェクト: psava/cwp12
  public void addRSFTensorEllipsoids() {

    _tpx = new TensorsPanel(_s1, _s2, _s3, _d);
    _tpy = new TensorsPanel(_s1, _s2, _s3, _d);
    ImagePanel ipx = _ipg.getImagePanel(Axis.X);
    ImagePanel ipy = _ipg.getImagePanel(Axis.Y);
    ipx.getFrame().addChild(_tpx);
    ipy.getFrame().addChild(_tpy);

    _tpx.setEllipsoidSize(8);
    _tpy.setEllipsoidSize(8);
  }
コード例 #6
0
ファイル: Haikdu.java プロジェクト: cwvh/haikdu
  public Haikdu(String filename) {
    try {
      familySource.Open(filename);
      int success = wrappedSource.Open(familySource, true);
      if (success < 0) {
        familySource.Close();
        wrappedSource.Close();
        rawSource = new Kdu_simple_file_source(filename);
      }

      if (rawSource != null) compositor.Create(rawSource);
      else compositor.Create(wrappedSource);

      int numThreads = Kdu_global.Kdu_get_num_processors();
      threadEnv.Create();
      for (int thread = 1; thread < numThreads; thread++)
        if (!threadEnv.Add_thread()) numThreads = thread;
      compositor.Set_thread_env(threadEnv, null);

      compositor.Add_ilayer(0, new Kdu_dims(), new Kdu_dims());
      compositor.Set_scale(false, false, false, 0.050f);

      // Determine dimensions for the rendered result and start processing.
      compositor.Get_total_composition_dims(viewDims);
      viewSize = viewDims.Access_size();

      // Construct Swing frame
      imagePanel = new ImagePanel(viewSize);
      addWindowListener(
          new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              System.exit(0);
            }
          });
      getContentPane().add("Center", imagePanel);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      pack();
      setTitle("Haikdu");
      setVisible(true);
      repaint();

      Kdu_coords displaySize = new Kdu_coords(imagePanel.getWidth(), imagePanel.getHeight());
      if (viewSize.Get_x() > displaySize.Get_x()) viewSize.Set_x(displaySize.Get_y());
      if (viewSize.Get_y() > displaySize.Get_y()) viewSize.Set_y(displaySize.Get_y());
      compositor.Set_buffer_surface(viewDims);
      compositorBuffer = compositor.Get_composition_buffer(viewDims);
    } catch (KduException e) {
      System.err.printf("Caught exception during Kdu object construction: %s\n", e.getMessage());
    }

    render();
  }
コード例 #7
0
ファイル: Haikdu.java プロジェクト: cwvh/haikdu
  public void render() {
    try {
      int regionBufferSize = 0;
      int[] regionBuffer = null;
      Kdu_dims newRegion = new Kdu_dims();

      long kduRenderStart = System.nanoTime();

      while (compositor.Process(100000, newRegion)) {
        Kdu_coords newOffset = newRegion.Access_pos();
        Kdu_coords newSize = newRegion.Access_size();

        newOffset.Subtract(viewDims.Access_pos());

        int newPixels = newSize.Get_x() * newSize.Get_y();
        if (newPixels == 0) continue;
        else if (newPixels > regionBufferSize) {
          regionBufferSize = newPixels;
          regionBuffer = new int[regionBufferSize];
        }

        compositorBuffer.Get_region(newRegion, regionBuffer);
        imagePanel.putRegion(
            viewSize.Get_x(),
            viewSize.Get_y(),
            newSize.Get_x(),
            newSize.Get_y(),
            newOffset.Get_x(),
            newOffset.Get_y(),
            regionBuffer);
      }

      long kduRenderEnd = System.nanoTime();

      System.out.printf(
          "Processed using %d concurrent threads of execution in %.4fms\n",
          threadEnv.Get_num_threads(), (kduRenderEnd - kduRenderStart) * 1e-6);
      imagePanel.repaint();
    } catch (KduException e) {
      System.err.printf(
          "Caught exception '%s'; code '%s'\n",
          e.getMessage(), Integer.toHexString(e.Get_kdu_exception_code()));
    }
  }
コード例 #8
0
 /**
  * Method to setup the active panel
  *
  * @param p
  * @return
  */
 private boolean setActivePanel(Point p) {
   activePanel = null;
   Rectangle r = Imp.getBounds();
   if (r.contains(p)) activePanel = Imp;
   r = p1.getBounds();
   if (r.contains(p)) activePanel = p1;
   r = Op.getBounds();
   if (r.contains(p)) activePanel = Op;
   r = p3.getBounds();
   if (r.contains(p)) activePanel = p3;
   if (activePanel != null) return true;
   return false;
 }
コード例 #9
0
  /**
   * Constructor.
   *
   * @param functions the array of functions to plot
   * @param graphPanel the parent graph panel
   */
  HeaderPanel(Plottable functions[], GraphPanel graphPanel) {
    this();
    this.graphPanel = graphPanel;

    fpDimensions = maxFunctionDimensions(functions);

    buttonPanel.setLayout(new FlowLayout());
    buttonPanel.add(headerButton);

    imagePanel.setSize(fpDimensions);

    functionCard.add(buttonPanel, BorderLayout.WEST);
    functionCard.add(imagePanel, BorderLayout.CENTER);

    cardLayout.show(this, FUNCTION);

    // Header button handler.
    headerButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            HeaderPanel.this.graphPanel.doHeaderAction(); // callback
          }
        });
  }
コード例 #10
0
ファイル: EditPanel.java プロジェクト: xoebus/hci-project
  @Override
  public void paintComponent(Graphics graphics) {
    super.paintComponent(graphics);

    Graphics2D g = (Graphics2D) graphics;
    g.setStroke(new BasicStroke(3));
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    if (image != null) {
      for (Blob blob : this.image.getBlobs()) {

        for (Point point : blob.getPoints()) {
          g.setColor(new Color(100, 100, 200, 20));

          int length = blob.getPoints().size();
          int[] xs = new int[length];
          int[] ys = new int[length];

          for (int i = 0; i < length; i++) {
            Point p = blob.getPoints().get(i);
            xs[i] = p.getX();
            ys[i] = p.getY();
          }
          g.fillPolygon(xs, ys, length);

          g.setColor(Color.green);

          if (blob == selectedBlob) {
            g.setColor(Color.red);
          }

          g.fillOval(point.getX() - 5, point.getY() - 5, 10, 10);

          int currentIndex = blob.getPoints().indexOf(point);

          Point lastPoint;

          if (currentIndex == 0) {
            lastPoint = blob.getPoints().get(blob.getPoints().size() - 1);
          } else {
            lastPoint = blob.getPoints().get(currentIndex - 1);
          }

          g.drawLine(point.getX(), point.getY(), lastPoint.getX(), lastPoint.getY());
        }
      }

      if (tempPoints == null) {
        return;
      }

      g.setColor(Color.green);

      for (Point point : tempPoints) {
        g.fillOval(point.getX() - 5, point.getY() - 5, 10, 10);
        int currentIndex = tempPoints.indexOf(point);

        if (currentIndex > 0) {
          Point lastPoint = tempPoints.get(currentIndex - 1);

          g.setColor(Color.green);
          g.drawLine(point.getX(), point.getY(), lastPoint.getX(), lastPoint.getY());
        }
      }
    }
  }
コード例 #11
0
 /**
  * Set a function and repaint the function panel.
  *
  * @param xSelection the selected function index
  */
 void setFunction(Plottable function) {
   this.function = function;
   cardLayout.show(this, FUNCTION);
   imagePanel.repaint();
 }
コード例 #12
0
  /**
   * method to set the dragndrop action when mouse is released
   *
   * @param e
   */
  public void mouseReleased(MouseEvent e) {

    /** get position if off glass panel then return */
    Point p = e.getPoint();
    if (!contains(glassPanel, selectedComponent)) return;

    /**
     * check drop point is on glasspanel this is copied form below and should be put into a new
     * method
     */
    Rectangle gP = glassPanel.getBounds();
    if (!gP.contains(p)) {
      glassPanel.remove(selectedComponent);
      OriP.add(selectedComponent);
      int x = Original.x;
      int y = Original.y;
      Dimension d = selectedComponent.getSize();
      selectedComponent.setBounds(x, y, d.width, d.height);
      return;
    }

    /** Calculate actions when dropped remove from glasspanel and set new active panel */
    glassPanel.remove(selectedComponent);
    setActivePanel(p);

    /** check whether the droppoint was over a symhooks point */
    Rectangle PanelA = new Rectangle(activePanel.getBounds());
    c1 = new Rectangle();
    for (int i = 0; i < SymHooks.length; i++) {
      c1.setBounds(SymHooks[i].getBounds());
      //     c1.setLocation(c1.x, c1.y + p1.getHeight());
      if (activePanel.equals(p3) && (c1.contains(p))) {
        activePanel.add(selectedComponent);
        Rectangle r = activePanel.getBounds();
        int x = p.x - offset.x - r.x;
        int y = p.y - offset.y - r.y;
        Dimension d = selectedComponent.getSize();
        selectedComponent.setBounds(x, y, d.width, d.height);
        dragging = false;
        dropflag = true;

        /** if the icon came from the ImagePanel then repopulate */
        if (OriP.equals(Imp)) {
          for (int j = 0; j < Symlab.length; j++) {
            if (Original.getY() == Symlab[j].getPosition().getY()) {
              newlabel = new JLabel();
              newlabel.setIcon(new ImageIcon(Symlab[j].getSymImage()));
              d = new Dimension();
              d = newlabel.getPreferredSize();
              newlabel.setBounds(
                  Symlab[j].getJLabel().getX(), Symlab[j].getJLabel().getY(), d.width, d.height);
              newlabel.setName(String.valueOf(Symlab[j].getType()));
              Imp.add(newlabel);
              JLabel test = (JLabel) selectedComponent;
            }
          }
        }
      }
    }

    /** if the drop point was over the waste box then don't replace at original site */
    if (WasteBox.contains(p) && (!OriP.equals(Imp))) {
      dropflag = true;
    }

    /** if not dropped then return to original position */
    if (!dropflag) {
      glassPanel.remove(selectedComponent);
      OriP.add(selectedComponent);
      int x = Original.x;
      int y = Original.y;
      Dimension d = selectedComponent.getSize();
      selectedComponent.setBounds(x, y, d.width, d.height);
    }
    dropflag = false;
    // activePanel.repaint();
    // OriP.repaint();
    glassPanel.repaint();
    activePanel = null;
  }
コード例 #13
0
 /** Open function: open a file chooser to select a new image file. */
 private void openFile() {
   OFImage image = ImageFileManager.getImage();
   imagePanel.setImage(image);
   frame.pack();
 }