コード例 #1
0
ファイル: OpenButton.java プロジェクト: mymindleaks/jLogics
  /*
   * (non-Javadoc)
   *
   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  public void actionPerformed(ActionEvent e) {
    FileReader fr = null;
    try {

      DigitalCircuit cir;
      fr = new FileReader("temp-cir.xml");
      cir = (DigitalCircuit) st.fromXML(fr);

      DigitalWindow win = new DigitalWindow(); // create a new window
      DrawingPad pad = win.getDrawingPad();
      pad.setCircuit(cir);

      MDIWindow.addWindow(win);
      win.show();

      fr.close();
    } catch (FileNotFoundException e1) {
      e1.printStackTrace();
    } catch (IOException e1) {
      e1.printStackTrace();
    } catch (Exception e1) {
      try {
        fr.close();
      } catch (IOException e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
      }
    }
  }
コード例 #2
0
ファイル: Util.java プロジェクト: mymindleaks/jLogics
  /**
   * @param g
   * @param s get the boundaryvalues for the shape
   */
  public static void paintTexture(Graphics2D g, Shape s, DrawingPad pad) {
    Rectangle r = s.getBounds();
    if (r.height <= 0 || r.width <= 0) return;
    /**
     * when the height and width of the symbol is greater than 0 then GraphicsConfiguration is set
     * to DeviceConnfiguration
     */
    GraphicsConfiguration config = g.getDeviceConfiguration();
    BufferedImage strip = (BufferedImage) pad.getImage();

    /** creates an object gstrip for drawing horizontal and vertical strip */
    Graphics2D gStrip = strip.createGraphics();

    horStrip(gStrip, strip, 0, r.width, 0);
    gStrip.dispose();

    Shape prevClip = g.getClip();
    if (!r.equals(s)) {
      g.clip(s);
    }

    vertStrip(g, strip, r.y, r.height, r.x);
    g.setClip(prevClip);
  }