예제 #1
0
  @Override
  public void setBounds(final int x, final int y, final int width, final int height) {
    super.setBounds(x, y, width, height);
    try {
      if (tiledBufferedImage != null) {
        bufferedImageAllocator.freeBufferedImage(tiledBufferedImage);
      }

      final AllocationMatch myAllocationMatch = new AllocationMatch();
      tiledBufferedImage =
          bufferedImageAllocator.allocateBufferedImage(
              "SourceSignalAmpMeter",
              myAllocationMatch,
              AllocationLifetime.SHORT,
              AllocationBufferType.TYPE_INT_RGB,
              width,
              height);
      outBufferedImage = tiledBufferedImage.getUnderlyingBufferedImage();
      outBufferedImageGraphics = outBufferedImage.createGraphics();
      outBufferedImageGraphics.setColor(Color.BLACK);
      outBufferedImageGraphics.fillRect(0, 0, componentWidth, componentHeight);
    } catch (final DatastoreException e) {
      if (log.isErrorEnabled()) {
        log.error("DatastoreException caught allocating buffered image: " + e.toString(), e);
      }
    }
    componentWidth = width;
    componentHeight = height;
  }
예제 #2
0
 public void destroy() {
   if (tiledBufferedImage != null) {
     try {
       bufferedImageAllocator.freeBufferedImage(tiledBufferedImage);
     } catch (final Exception e) {
       final String msg = "Failed to free up allocated image: " + e.toString();
       log.error(msg);
     }
     tiledBufferedImage = null;
     outBufferedImage = null;
     outBufferedImageGraphics = null;
   }
 }