Exemplo n.º 1
0
  /** @param master */
  public Renderer(JavaDesktopFrontend master) {
    this.plugin = master;
    this.I18n = plugin.getApi().getI18n();
    environmentWidth = (int) getEnvironments().get(0).getPojo().getWidth();
    environmentHeight = (int) getEnvironments().get(0).getPojo().getHeight();
    CANVAS_WIDTH = environmentWidth + (BORDER_X * 2);
    CANVAS_HEIGHT = environmentHeight + (BORDER_Y * 2);
    backgroundColor =
        TopologyUtils.convertColorToAWT(getEnvironments().get(0).getPojo().getBackgroundColor());
    calloutsUpdater = new CalloutsUpdater(this, 900);
    currEnv = getEnvironments().get(0);
    ResourcesManager.clear();
    clear();
    addCustomMouseListener();
    addCustomMouseMotionListener();
    setBackground(backgroundColor);
    addComponentListener(
        new ComponentAdapter() {

          @Override
          public void componentResized(ComponentEvent e) {
            backgroundChanged = true;
            findRescaleFactor();
          }
        });
    repaint();
  }
Exemplo n.º 2
0
  /**
   * @param icon
   * @param x
   * @param y
   * @param dimension
   */
  protected void paintImageCentredOnCoords(String icon, int x, int y, Dimension dimension) {
    BufferedImage img = null;
    img =
        ResourcesManager.getResource(icon, (int) dimension.getWidth(), (int) dimension.getHeight());

    if (img != null) {
      getContext().drawImage(img, x - (img.getWidth() / 2), y - (img.getHeight() / 2), this);
    }
  }
Exemplo n.º 3
0
  @Override
  public void prepareBackground() {
    BufferedImage img = null;
    String fileName = getCurrEnv().getPojo().getBackgroundImage();
    img =
        ResourcesManager.getResource(
            fileName, getCurrEnv().getPojo().getWidth(), getCurrEnv().getPojo().getHeight());

    if (img != null) {
      getContext().drawImage(img, 0, 0, this);
    } else {
      LOG.warning("Cannot find environment background image " + fileName);
    }
  }
Exemplo n.º 4
0
  /**
   * @param textureFile
   * @param shape
   */
  protected void paintTexture(String textureFile, Shape shape) {
    BufferedImage img = null;
    Graphics2D g2 = (Graphics2D) getContext();

    if (textureFile != null) {
      img = ResourcesManager.getResource(textureFile);

      if (img != null) {
        Rectangle2D replicationPath = new Rectangle2D.Double(0, 0, img.getWidth(), img.getHeight());
        TexturePaint texture = new TexturePaint(img, replicationPath);
        g2.setPaint(texture);
        g2.fill(shape);
      }
    }
  }
Exemplo n.º 5
0
  /**
   * @param obj
   * @throws RuntimeException
   */
  protected void paintImage(EnvObject obj) {

    BufferedImage img =
        ResourcesManager.getResource(
            obj.getCurrentRepresentation().getIcon(), -1, -1); // -1 means no resizeing

    if (img != null) {
      getContext().drawImage(img, 0, 0, this);
    } else {
      throw new RuntimeException(
          "Cannot find image "
              + obj.getCurrentRepresentation().getIcon()
              + " for object "
              + obj.getName());
    }
  }
 @Override
 public BufferedImage getResource(String resourceIdentifier) {
   return ResourcesManager.getResource(resourceIdentifier);
 }