Package org.tomighty.resources.cache

Examples of org.tomighty.resources.cache.Cache


    return image;
  }

  public Image time(Time time) {
    String iconName = iconNameFor(time);
    Cache cache = caches.of(Icons.class);
    if (cache.contains(iconName)) {
      return cache.get(iconName);
    }

    Dimension size = tray.iconSize();
    Colors colors = look.colors();
    Canvas canvas = new Canvas(size);
    canvas.fontSize((float) size.height * 0.58f);
    canvas.paintGradient(colors.background());
    canvas.drawBorder(colors.background().darker().darker().darker());
    canvas.drawCentralizedText(time.shortestString());

    cache.store(canvas.image(), iconName);

    return canvas.image();
  }
View Full Code Here


  protected abstract void paint(Canvas canvas, Look look);
 
  @Override
  public final void paint(Canvas canvas) {
    Colors colors = look.colors();
    Cache cache = caches.of(Images.class);
    String name = getClass().getSimpleName() + "_" + colors.getClass().getSimpleName();
    Image image = cache.get(name);
    if(image == null) {
      paint(canvas, look);
      cache.store(canvas.image(), name);
    } else {
      canvas.paint(image);
    }
  }
View Full Code Here

TOP

Related Classes of org.tomighty.resources.cache.Cache

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.