public void initTarget(PreviewUIModel previewUIModel) {
    // inits the preview applet
    if (previewUIModel != null && target == null) {
      PreviewController previewController = Lookup.getDefault().lookup(PreviewController.class);
      Color background =
          previewController
              .getModel()
              .getProperties()
              .getColorValue(PreviewProperty.BACKGROUND_COLOR);
      if (background != null) {
        setBackgroundColor(background);
      }

      target = (ProcessingTarget) previewController.getRenderTarget(RenderTarget.PROCESSING_TARGET);
      if (target != null) {
        sketch = target.getApplet();
        sketch.init();
        sketch.registerPost(processingListener);
        sketch.registerPre(processingListener);
        sketchPanel.add(sketch, BorderLayout.CENTER);
      }
    } else if (previewUIModel == null) {
      sketchPanel.remove(sketch);
      target = null;
    }
  }
Exemplo n.º 2
0
 public void init() {
   if (frame != null) {
     frame.removeNotify(); // make the frame not displayable
     frame.setResizable(true);
     frame.setUndecorated(true);
     println("frame is at " + frame.getLocation());
     frame.addNotify();
   }
   super.init();
 }
Exemplo n.º 3
0
 public DisplayFrame() {
   this.setSize(1000, 800); // The window Dimensions
   setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
   javax.swing.JPanel panel = new javax.swing.JPanel();
   panel.setBounds(20, 20, 1000, 800);
   PApplet sketch = new CTCOffice();
   panel.add(sketch);
   this.add(panel);
   sketch.init(); // this is the function used to start the execution of the sketch
   this.setVisible(true);
   this.setTitle("Breathless Bovine: CTC Office         by Jake Lyons");
 }
Exemplo n.º 4
0
 public void init() {
   if (frame != null) {
     frame.removeNotify(); // make the frame not displayable
     frame.addWindowStateListener(
         new WindowStateListener() {
           public void windowStateChanged(WindowEvent arg0) {
             frame__windowStateChanged(arg0);
           }
         });
     frame.addNotify();
   }
   super.init();
 }
  /**
   * Instantiates a new internal debug window.
   *
   * @param displayHoriz the display horiz
   * @param the maximal x size of the window
   */
  public GeneratorGuiCreator(int maximalXSize, int maximalYSize, String version) {
    int nrOfScreens = Collector.getInstance().getAllVisuals().size();
    LOG.log(Level.INFO, "create GUI, nr of screens: " + nrOfScreens);

    Generator g = Collector.getInstance().getPixelControllerGenerator().getGenerator(0);
    float aspect = (float) g.getInternalBufferXSize() / (float) g.getInternalBufferYSize();

    int singleVisualXSize = 0, singleVisualYSize = 1000;

    while (singleVisualYSize > maximalYSize) {
      singleVisualXSize = maximalXSize / nrOfScreens;
      singleVisualYSize = (int) (maximalXSize / nrOfScreens / aspect);
      maximalXSize -= 100;
    }

    int windowXSize = singleVisualXSize * nrOfScreens;
    int windowYSize = singleVisualYSize + 350;

    // ugly boarder stuff
    windowXSize += 20;

    if (windowXSize < MINIMAL_WINDOW_X_SIZE) {
      windowXSize = MINIMAL_WINDOW_X_SIZE;
    }

    // connect the new PApplet to our frame
    gui = new GeneratorGui(windowXSize, windowYSize, singleVisualXSize, singleVisualYSize);
    gui.init();

    // create new window for child
    LOG.log(
        Level.INFO,
        "create frame with size " + windowXSize + "/" + windowYSize + ", aspect: " + aspect);
    JFrame childFrame = new JFrame("PixelController Generator Window " + version);
    childFrame.setResizable(false);
    childFrame.setIconImage(GeneratorGuiCreator.createLargeIcon());

    childFrame.add(gui);

    childFrame.setBounds(0, 0, windowXSize, windowYSize + 30);
    gui.setBounds(0, 0, windowXSize, windowYSize + 30);

    // important to call this whenever embedding a PApplet.
    // It ensures that the animation thread is started and
    // that other internal variables are properly set.
    childFrame.setVisible(true);

    // childFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    childFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    childFrame.addWindowListener(new WindowHandler());
  }
  /** Creates new form NewJFrame */
  public NewJFrame() {
    super("Embedded PApplet");

    initComponents();

    setLayout(new BorderLayout());
    PApplet embed = new MyEarthquakeCityMap(); // FOR EARTHQUAKES
    // PApplet embed = new MyMapFirst(); //FOR MY MAP
    add(embed, BorderLayout.CENTER);

    // important to call this whenever embedding a PApplet.
    // It ensures that the animation thread is started and
    // that other internal variables are properly set.
    embed.init();
  }
Exemplo n.º 7
0
  public static void main(String[] argv) {
    List<String> args = Arrays.asList(argv);

    if (args.size() % 2 == 1 || args.contains("--help") || args.contains("-h")) {
      usage();
      return;
    }

    PApplet processing = new PApplet();

    processing.init();
    processing.start();

    try {
      WordCram wordCram =
          new WordCram(processing)
              .fromTextString(PApplet.loadStrings(System.in))
              .withColorer(Colorers.twoHuesRandomSats(processing))
              .withAngler(Anglers.mostlyHoriz())
              .withWordPadding(4)
              .withPlacer(Placers.centerClump());

      ImageConfiguration imageConfig = parseArgs(args, wordCram);

      PGraphics image = processing.createGraphics(imageConfig.width, imageConfig.height, JAVA2D);
      try {
        wordCram.withCustomCanvas(image);

        image.beginDraw();
        wordCram.drawAll();
        image.endDraw();

        image.save(imageConfig.fileName);

      } finally {
        image.dispose();
      }

      processing.stop();
      System.exit(0);

    } catch (Throwable t) {
      System.err.println(t.getMessage());
      System.exit(1);
    }
  }
Exemplo n.º 8
0
  private void setupWithPApplet(
      PApplet applet, int appletFrameWidth, int appletFrameHeight, boolean frameVisible) {
    this.applet = applet;
    this.frameVisible = frameVisible;

    frame = new JFrame();
    frame.setLayout(new BorderLayout());
    frame.setSize(appletFrameWidth, appletFrameHeight);
    if (frameVisible) frame.setVisible(true);
    frame.add(applet, BorderLayout.CENTER);
    frame.setResizable(false);

    applet.registerMethod("pre", this);
    applet.registerMethod("post", this);

    applet.init();
  }
  /**
   * Instantiates a new internal debug window.
   *
   * @param displayHoriz the display horiz
   * @param the maximal x size of the window
   */
  public GeneratorGuiCreator(
      PApplet parentPapplet, int maximalXSize, int maximalYSize, String version) {
    int nrOfScreens = Collector.getInstance().getAllVisuals().size();
    LOG.log(Level.INFO, "create GUI, nr of screens: " + nrOfScreens);

    Generator g = Collector.getInstance().getPixelControllerGenerator().getGenerator(0);
    WindowSizeCalculator wsc =
        new WindowSizeCalculator(
            g.getInternalBufferXSize(),
            g.getInternalBufferYSize(),
            maximalXSize,
            maximalYSize,
            nrOfScreens);

    // connect the new PApplet to our frame
    gui = new GeneratorGui(wsc);
    gui.init();

    // create new window for child
    LOG.log(Level.INFO, "Create new window: " + wsc);
    JFrame childFrame = new JFrame("PixelController Generator Window " + version);
    childFrame.setResizable(false);
    childFrame.setIconImage(createLargeIcon(gui));

    childFrame.add(gui);

    childFrame.setBounds(0, 0, wsc.getWindowWidth(), wsc.getWindowHeight() + 30);
    gui.setBounds(0, 0, wsc.getWindowWidth(), wsc.getWindowHeight() + 30);

    // important to call this whenever embedding a PApplet.
    // It ensures that the animation thread is started and
    // that other internal variables are properly set.
    childFrame.setVisible(true);

    // childFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    childFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    childFrame.addWindowListener(new WindowHandler(parentPapplet));
  }