Package org.jwildfire.create.tina.swing.flamepanel

Examples of org.jwildfire.create.tina.swing.flamepanel.FlamePanel


    if (flamePanel == null) {
      int width = swfAnimatorPreviewRootPanel.getWidth();
      int height = swfAnimatorPreviewRootPanel.getHeight();
      SimpleImage img = new SimpleImage(width, height);
      img.fillBackground(0, 0, 0);
      flamePanel = new FlamePanel(prefs, img, 0, 0, swfAnimatorPreviewRootPanel.getWidth(), this, null);
      ResolutionProfile resProfile = getResolutionProfile();
      flamePanel.setRenderWidth(resProfile.getWidth());
      flamePanel.setRenderHeight(resProfile.getHeight());
      flamePanel.setFocusable(true);
      swfAnimatorPreviewRootPanel.add(flamePanel, BorderLayout.CENTER);
View Full Code Here


    return getCurrFlame();
  }

  public void refreshFlameImage(boolean pQuickRender) {
    if (!noRefresh) {
      FlamePanel imgPanel = getFlamePanel();
      Rectangle bounds = imgPanel.getImageBounds();
      int width = bounds.width;
      int height = bounds.height;
      if (width >= 16 && height >= 16) {
        RenderInfo info = new RenderInfo(width, height, RenderMode.PREVIEW);
        Flame flame = getCurrFlame();
        if (flame != null) {
          double oldSpatialFilterRadius = flame.getSpatialFilterRadius();
          double oldSampleDensity = flame.getSampleDensity();
          try {
            double wScl = (double) info.getImageWidth() / (double) flame.getWidth();
            double hScl = (double) info.getImageHeight() / (double) flame.getHeight();
            flame.setPixelsPerUnit((wScl + hScl) * 0.5 * flame.getPixelsPerUnit());
            flame.setWidth(info.getImageWidth());
            flame.setHeight(info.getImageHeight());

            FlameRenderer renderer = new FlameRenderer(flame, prefs, false, false);
            if (pQuickRender) {
              renderer.setProgressUpdater(null);
              flame.setSampleDensity(1.0);
              flame.setSpatialFilterRadius(0.0);
            }
            else {
              renderer.setProgressUpdater(renderProgressUpdater);
              flame.setSampleDensity(prefs.getTinaRenderPreviewQuality());
            }
            RenderedFlame res = renderer.renderFlame(info);
            imgPanel.setImage(res.getImage());
          }
          finally {
            flame.setSpatialFilterRadius(oldSpatialFilterRadius);
            flame.setSampleDensity(oldSampleDensity);
          }
        }
      }
      else {
        imgPanel.setImage(new SimpleImage(width, height));
      }
      swfAnimatorPreviewRootPanel.repaint();
    }
  }
View Full Code Here

    if (flamePanel == null) {
      int width = centerPanel.getWidth();
      int height = centerPanel.getHeight();
      SimpleImage img = new SimpleImage(width, height);
      img.fillBackground(0, 0, 0);
      flamePanel = new FlamePanel(prefs, img, 0, 0, centerPanel.getWidth(), this, this);
      flamePanel.getConfig().setWithColoredTransforms(prefs.isTinaEditorControlsWithColor());
      flamePanel.setFlamePanelTriangleMode(prefs.getTinaEditorControlsStyle());
      flamePanel.importOptions(prevFlamePanel);
      prevFlamePanel = null;
      flamePanel.setUndoManagerHolder(this);
View Full Code Here

  public void refreshFlameImage(boolean pQuickRender, boolean pMouseDown, int pDownScale) {
    if (pQuickRender && detachedPreviewController != null && pDownScale == 1) {
      detachedPreviewController.setFlame(getCurrFlame());
    }

    FlamePanel imgPanel = getFlamePanel();
    FlamePanelConfig cfg = getFlamePanelConfig();
    Rectangle panelBounds = imgPanel.getImageBounds();
    Rectangle bounds;
    if (pDownScale != 1) {
      bounds = new Rectangle(panelBounds.width / pDownScale, panelBounds.height / pDownScale);
    }
    else {
      bounds = panelBounds;
    }

    int renderScale = pQuickRender && pMouseDown ? 2 : 1;
    int width = bounds.width / renderScale;
    int height = bounds.height / renderScale;
    if (width >= 16 && height >= 16) {
      RenderInfo info = new RenderInfo(width, height, RenderMode.PREVIEW);
      Flame flame = getCurrFlame();
      if (flame != null) {
        double oldSpatialFilterRadius = flame.getSpatialFilterRadius();
        double oldSampleDensity = flame.getSampleDensity();
        try {
          double wScl = (double) info.getImageWidth() / (double) flame.getWidth();
          double hScl = (double) info.getImageHeight() / (double) flame.getHeight();
          flame.setPixelsPerUnit((wScl + hScl) * 0.5 * flame.getPixelsPerUnit());
          flame.setWidth(info.getImageWidth());
          flame.setHeight(info.getImageHeight());
          try {
            FlameRenderer renderer;
            if (!cfg.isNoControls() && imgPanel.getConfig().getMouseDragOperation() == MouseDragOperation.FOCUS) {
              renderer = new DrawFocusPointFlameRenderer(flame, prefs, data.toggleTransparencyButton.isSelected());
            }
            else {
              renderer = new FlameRenderer(flame, prefs, data.toggleTransparencyButton.isSelected(), false);
            }
            if (pQuickRender) {
              renderer.setProgressUpdater(null);
              flame.setSampleDensity(prefs.getTinaRenderRealtimeQuality());
              flame.setSpatialFilterRadius(0.0);
            }
            else {
              renderer.setProgressUpdater(mainProgressUpdater);
              flame.setSampleDensity(prefs.getTinaRenderPreviewQuality());
            }
            renderer.setRenderScale(renderScale);
            long t0 = System.currentTimeMillis();
            RenderedFlame res = renderer.renderFlame(info);
            long t1 = System.currentTimeMillis();
            SimpleImage img = res.getImage();
            img.getBufferedImg().setAccelerationPriority(1.0f);

            if (data.layerAppendBtn.isSelected() && !pMouseDown) {
              TextTransformer txt = new TextTransformer();
              txt.setText1("layer-append-mode active");
              txt.setAntialiasing(true);
              txt.setColor(Color.RED);
              txt.setMode(Mode.NORMAL);
              txt.setFontStyle(FontStyle.BOLD);
              txt.setFontName("Arial");
              txt.setFontSize(16);
              txt.setHAlign(HAlignment.RIGHT);
              txt.setVAlign(VAlignment.BOTTOM);
              txt.transformImage(img);
            }

            if (data.layerPreviewBtn.isSelected()) {
              Layer onlyVisibleLayer = null;
              for (Layer layer : getCurrFlame().getLayers()) {
                if (layer.isVisible()) {
                  if (onlyVisibleLayer == null) {
                    onlyVisibleLayer = layer;
                  }
                  else {
                    onlyVisibleLayer = null;
                    break;
                  }
                }
              }
              boolean drawSubLayer = flame.getLayers().size() > 1 && getCurrLayer() != null && getCurrLayer() != onlyVisibleLayer && !cfg.isNoControls();

              if (drawSubLayer) {
                Flame singleLayerFlame = new Flame();
                singleLayerFlame.assign(flame);
                singleLayerFlame.getLayers().clear();
                singleLayerFlame.getLayers().add(getCurrLayer().makeCopy());
                singleLayerFlame.getFirstLayer().setVisible(true);
                singleLayerFlame.getFirstLayer().setWeight(1.0);
                RenderInfo lInfo = new RenderInfo(width / 4 * renderScale, height / 4 * renderScale, RenderMode.PREVIEW);
                double lWScl = (double) lInfo.getImageWidth() / (double) singleLayerFlame.getWidth();
                double lHScl = (double) lInfo.getImageHeight() / (double) singleLayerFlame.getHeight();
                singleLayerFlame.setPixelsPerUnit((lWScl + lHScl) * 0.5 * singleLayerFlame.getPixelsPerUnit() * 0.5);
                singleLayerFlame.setWidth(lInfo.getImageWidth());
                singleLayerFlame.setHeight(lInfo.getImageHeight());
                FlameRenderer lRenderer = new FlameRenderer(singleLayerFlame, prefs, false, false);
                RenderedFlame lRes = lRenderer.renderFlame(lInfo);
                SimpleImage layerImg = lRes.getImage();

                boolean drawLayerNumber = true;
                if (drawLayerNumber) {
                  RectangleTransformer rT = new RectangleTransformer();
                  int textWidth = 28;
                  int textHeight = 22;
                  int margin = 2;

                  rT.setColor(new java.awt.Color(0, 0, 0));
                  rT.setLeft(layerImg.getImageWidth() - textWidth - 2 * margin);
                  rT.setTop(layerImg.getImageHeight() - textHeight - 2 * margin);
                  rT.setThickness(textHeight / 2 + 1);
                  rT.setWidth(textWidth);
                  rT.setHeight(textHeight);
                  rT.transformImage(layerImg);

                  TextTransformer txt = new TextTransformer();
                  txt.setText1("  " + (flame.getLayers().indexOf(getCurrLayer()) + 1) + "  ");
                  txt.setAntialiasing(true);
                  txt.setColor(new java.awt.Color(200, 200, 200));
                  txt.setMode(Mode.NORMAL);
                  txt.setFontStyle(FontStyle.BOLD);
                  txt.setFontName("Arial");
                  txt.setFontSize(16);
                  txt.setHAlign(HAlignment.NONE);
                  txt.setPosX(layerImg.getImageWidth() - textWidth - margin);
                  txt.setPosY(layerImg.getImageHeight() - textHeight - margin);
                  txt.setVAlign(VAlignment.NONE);
                  txt.transformImage(layerImg);
                }

                RectangleTransformer rT = new RectangleTransformer();
                rT.setColor(new java.awt.Color(200, 200, 200));
                rT.setLeft(0);
                rT.setTop(0);
                rT.setThickness(3);
                rT.setWidth(lInfo.getImageWidth());
                rT.setHeight(lInfo.getImageHeight());
                rT.transformImage(layerImg);

                ComposeTransformer cT = new ComposeTransformer();
                cT.setHAlign(ComposeTransformer.HAlignment.LEFT);
                cT.setVAlign(ComposeTransformer.VAlignment.BOTTOM);
                cT.setTop(10);
                cT.setLeft(10);
                cT.setForegroundImage(layerImg);
                cT.transformImage(img);
              }
            }

            if (pDownScale != 1) {
              SimpleImage background = new SimpleImage(panelBounds.width, panelBounds.height);
              ComposeTransformer cT = new ComposeTransformer();
              cT.setHAlign(ComposeTransformer.HAlignment.CENTRE);
              cT.setVAlign(ComposeTransformer.VAlignment.CENTRE);
              cT.setForegroundImage(img);
              cT.transformImage(background);
              img = background;
            }

            imgPanel.setImage(img);
            if (!cfg.isNoControls()) {
              showStatusMessage(flame, "render time: " + Tools.doubleToString((t1 - t0) * 0.001) + "s");
            }
          }
          catch (Throwable ex) {
            errorHandler.handleError(ex);
          }
        }
        finally {
          flame.setSpatialFilterRadius(oldSpatialFilterRadius);
          flame.setSampleDensity(oldSampleDensity);
        }
      }
      if (!pMouseDown && !cfg.isNoControls()) {
        for (int i = 0; i < randomBatch.size(); i++) {
          Flame bFlame = randomBatch.get(i).getFlame();
          if (bFlame == flame) {
            randomBatch.get(i).preview = null;
            ImagePanel pnl = randomBatch.get(i).getImgPanel();
            if (pnl != null) {
              pnl.replaceImage(randomBatch.get(i).getPreview(prefs.getTinaRenderPreviewQuality() / 2));
              pnl.repaint();
            }
            break;
          }
        }
      }
    }

    if (!cfg.isNoControls()) {
      centerPanel.getParent().validate();
      centerPanel.repaint();
    }
    else {
      imgPanel.repaint();
    }
  }
View Full Code Here

  public void importFromRandomBatch(int pIdx) {
    if (pIdx >= 0 && pIdx < randomBatch.size()) {
      setCurrFlame(randomBatch.get(pIdx).getFlame(), false);
      undoManager.initUndoStack(getCurrFlame());
      {
        FlamePanel imgPanel = getFlamePanel();
        Rectangle bounds = imgPanel.getImageBounds();
        double wScl = (double) bounds.width / (double) getCurrFlame().getWidth();
        double hScl = (double) bounds.height / (double) getCurrFlame().getHeight();
        getCurrFlame().setWidth(bounds.width);
        getCurrFlame().setHeight(bounds.height);
        getCurrFlame().setPixelsPerUnit((wScl + hScl) * 0.5 * getCurrFlame().getPixelsPerUnit());
 
View Full Code Here

    if (flamePanel == null) {
      int width = getPreviewRootPanel().getWidth();
      int height = getPreviewRootPanel().getHeight();
      SimpleImage img = new SimpleImage(width, height);
      img.fillBackground(0, 0, 0);
      flamePanel = new FlamePanel(Prefs.getPrefs(), img, 0, 0, getPreviewRootPanel().getWidth(), this, null);
      flamePanel.setRenderWidth(800);
      flamePanel.setRenderHeight(600);
      flamePanel.setFocusable(true);
      getPreviewRootPanel().add(flamePanel, BorderLayout.CENTER);
      getPreviewRootPanel().getParent().validate();
View Full Code Here

    }
    return flamePanel;
  }

  public void refreshFlameImage() {
    FlamePanel imgPanel = getFlamePanel();
    Rectangle bounds = imgPanel.getImageBounds();
    int width = bounds.width;
    int height = bounds.height;
    if (width >= 16 && height >= 16) {
      RenderInfo info = new RenderInfo(width, height, RenderMode.PREVIEW);
      Flame flame = getFlame();
      if (flame != null) {
        double oldSpatialFilterRadius = flame.getSpatialFilterRadius();
        double oldSampleDensity = flame.getSampleDensity();
        try {
          double wScl = (double) info.getImageWidth() / (double) flame.getWidth();
          double hScl = (double) info.getImageHeight() / (double) flame.getHeight();
          flame.setPixelsPerUnit((wScl + hScl) * 0.5 * flame.getPixelsPerUnit());
          flame.setWidth(info.getImageWidth());
          flame.setHeight(info.getImageHeight());

          FlameRenderer renderer = new FlameRenderer(flame, Prefs.getPrefs(), false, false);
          renderer.setProgressUpdater(null);
          flame.setSampleDensity(Prefs.getPrefs().getTinaRenderRealtimeQuality() * 6.0);
          flame.setSpatialFilterRadius(0.0);
          RenderedFlame res = renderer.renderFlame(info);
          imgPanel.setImage(res.getImage());
        }
        finally {
          flame.setSpatialFilterRadius(oldSpatialFilterRadius);
          flame.setSampleDensity(oldSampleDensity);
        }
      }
    }
    else {
      imgPanel.setImage(new SimpleImage(width, height));
    }
    getPreviewRootPanel().repaint();
  }
View Full Code Here

    }
  }

  public void refreshFlameImage(boolean pQuickRender, JPanel pRootPanel, FlameHolder pFlameHolder) {
    if (!refreshing) {
      FlamePanel imgPanel = getFlamePanel(pRootPanel, pFlameHolder);
      Rectangle bounds = imgPanel.getImageBounds();
      int width = bounds.width;
      int height = bounds.height;
      if (width >= 16 && height >= 16) {
        RenderInfo info = new RenderInfo(width, height, RenderMode.PREVIEW);
        Flame flame = pFlameHolder.getFlame();
        if (flame != null) {
          double oldSpatialFilterRadius = flame.getSpatialFilterRadius();
          double oldSampleDensity = flame.getSampleDensity();
          try {
            double wScl = (double) info.getImageWidth() / (double) flame.getWidth();
            double hScl = (double) info.getImageHeight() / (double) flame.getHeight();
            flame.setPixelsPerUnit((wScl + hScl) * 0.5 * flame.getPixelsPerUnit());
            flame.setWidth(info.getImageWidth());
            flame.setHeight(info.getImageHeight());

            FlameRenderer renderer = new FlameRenderer(flame, prefs, false, false);
            if (pQuickRender) {
              renderer.setProgressUpdater(null);
              flame.setSampleDensity(3.0);
              flame.setSpatialFilterRadius(0.0);
            }
            else {
              renderer.setProgressUpdater(renderSequenceProgressUpdater);
              flame.setSampleDensity(prefs.getTinaRenderPreviewQuality());
            }
            RenderedFlame res = renderer.renderFlame(info);
            imgPanel.setImage(res.getImage());
          }
          finally {
            flame.setSpatialFilterRadius(oldSpatialFilterRadius);
            flame.setSampleDensity(oldSampleDensity);
          }
        }
      }
      else {
        imgPanel.setImage(new SimpleImage(width, height));
      }
      pRootPanel.repaint();
    }
  }
View Full Code Here

  }

  private Map<JPanel, FlamePanel> flamepanels = new HashMap<JPanel, FlamePanel>();

  private FlamePanel getFlamePanel(JPanel pRootPanel, FlameHolder pFlameHolder) {
    FlamePanel flamePanel = flamepanels.get(pRootPanel);
    if (flamePanel == null) {
      int width = pRootPanel.getWidth();
      int height = pRootPanel.getHeight();
      SimpleImage img = new SimpleImage(width, height);
      img.fillBackground(0, 0, 0);
      flamePanel = new FlamePanel(prefs, img, 0, 0, pRootPanel.getWidth(), pFlameHolder, null);
      flamePanel.setRenderWidth(renderWidthREd.getIntValue());
      flamePanel.setRenderHeight(renderHeightREd.getIntValue());
      flamePanel.setFocusable(true);
      pRootPanel.add(flamePanel, BorderLayout.CENTER);
      pRootPanel.getParent().validate();
      pRootPanel.repaint();
      flamePanel.requestFocusInWindow();
      flamepanels.put(pRootPanel, flamePanel);
    }
    return flamePanel;
  }
View Full Code Here

    }
    return flamePanel;
  }

  private void removeFlamePanel(JPanel pRootPanel) {
    FlamePanel flamePanel = flamepanels.get(pRootPanel);
    if (flamePanel != null) {
      pRootPanel.remove(flamePanel);
      flamepanels.remove(pRootPanel);
    }
  }
View Full Code Here

TOP

Related Classes of org.jwildfire.create.tina.swing.flamepanel.FlamePanel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.