@Override public void onSuccess(Image image) { groundTruthLayer = graphics().createImageLayer(image); rootLayer.addAt(groundTruthLayer, 3 * width, 0); }
protected static ImageLayer createDescripLayer(String descrip, float width) { return graphics().createImageLayer(wrapText(descrip, width, TextBlock.Align.CENTER)); }
protected static ImageLayer createButton (String text, final Runnable onClick) { CanvasImage image = formatText(text, true); ImageLayer button = graphics().createImageLayer(image); button.addListener(new Pointer.Adapter() { @Override public void onPointerStart(Pointer.Event event) { onClick.run(); } }); return button; }
@Override public void onSuccess(Image image) { rootLayer.addAt(graphics().createImageLayer(image), 5*width, 0); addDescrip("ground truth", 5*width, offset+height, width); }
private void addTestCanvas(int width, int height, Drawer drawer) { CanvasImage image = createCanvasImage(width, height, drawer); addTestLayer(width, height, graphics().createImageLayer(image)); }
public Label(float wid, float hei, TextFormat format) { image = graphics().createImage(wid, hei); layer = graphics().createImageLayer(image); this.format = format; }
private void addTestCanvas(String descrip, int width, int height, Drawer drawer) { CanvasImage image = createCanvasImage(width, height, drawer); addTestLayer(descrip, width, height, graphics().createImageLayer(image)); }
@Override public void done(Image image) { groundTruthLayer = graphics().createImageLayer(image); groundTruthLayer.transform().translate(3 * width, 0); rootLayer.add(groundTruthLayer); }
@Override public void done(Image image) { groundTruthLayer = graphics().createImageLayer(image); groundTruthLayer.transform().translate(4 * width, 0); rootLayer.add(groundTruthLayer); }
ImageLayer createButton (final Test test) { ImageLayer layer = graphics().createImageLayer(makeButtonImage(test.getName())); layer.addListener(new Pointer.Adapter() { @Override public void onPointerStart(Pointer.Event event) { startTest(test); } }); return layer; }
protected void fragment(String source, Image image, float ox, float oy) { float hw = image.width()/2f, hh = image.height()/2f; Image ul = image.subImage(0, 0, hw, hh); Image ur = image.subImage(hw, 0, hw, hh); Image ll = image.subImage(0, hh, hw, hh); Image lr = image.subImage(hw, hh, hw, hh); Image ctr = image.subImage(hw/2, hh/2, hw, hh); float dx = hw + 10, dy = hh + 10; GroupLayer group = graphics().createGroupLayer(); group.addAt(graphics().createImageLayer(ul), 0, 0); group.addAt(graphics().createImageLayer(ur), dx, 0); group.addAt(graphics().createImageLayer(ll), 0, dy); group.addAt(graphics().createImageLayer(lr), dx, dy); group.addAt(graphics().createImageLayer(ctr), dx/2, 2*dy); float xoff = image.width() + 20; group.addAt(scaleLayer(graphics().createImageLayer(ul), 2), xoff, 0); group.addAt(scaleLayer(graphics().createImageLayer(ur), 2), xoff+2*dx, 0); group.addAt(scaleLayer(graphics().createImageLayer(ll), 2), xoff, 2*dy); group.addAt(scaleLayer(graphics().createImageLayer(lr), 2), xoff+2*dx, 2*dy); graphics().rootLayer().addAt(group, ox, oy); addDescrip(source + " split into subimages, and scaled", ox, oy + image.height()*2 + 25, 3*image.width()+40); }
private void addTestCanvas(String descrip, int width, int height, String imagePath, final ImageDrawer drawer) { final CanvasImage target = graphics().createImage(width, height); assets().getImage(imagePath).addCallback(new Callback<Image>() { public void onSuccess(Image image) { drawer.draw(target.canvas(), image); } public void onFailure(Throwable err) { System.err.println("Oops! " + err); } }); addTestLayer(descrip, width, height, graphics().createImageLayer(target)); }
private void addTestCanvas(int width, int height, String imagePath, final ImageDrawer drawer) { final CanvasImage target = graphics().createImage(width, height); assets().getImage(imagePath).addCallback(new ResourceCallback<Image>() { public void done(Image image) { drawer.draw(target.canvas(), image); } public void error(Throwable err) { System.err.println("Oops! " + err); } }); addTestLayer(width, height, graphics().createImageLayer(target)); } }
@Override public void init() { setLifecycleListener(new LifecycleListener() { private double start = currentTime(); private int elapsed() { return (int)Math.round((currentTime() - start)/1000); } @Override public void onPause() { log().info("Paused " + elapsed()); notifications.add("Paused at " + elapsed() + "s"); } @Override public void onResume() { log().info("Resumed " + elapsed()); notifications.add("Resumed at " + elapsed() + "s"); updateDisplay(); } @Override public void onExit() {} // nada }); layer = graphics().createImageLayer(); updateDisplay(); graphics().rootLayer().addAt(layer, 15, 15); }
@Override public void init() { CanvasImage canvasImage = graphics().createImage(graphics().width(), graphics().height()); canvas = canvasImage.canvas(); graphics().rootLayer().add(graphics().createImageLayer(canvasImage)); }
@Override public void init() { // remove the background layer added by default graphics().rootLayer().removeAll(); // add a grey square SurfaceImage surf = graphics().createSurface(width, height); surf.surface().setFillColor(Color.rgb(200, 200, 200)); surf.surface().fillRect(0, 0, width, height); square = graphics().createImageLayer(surf); graphics().rootLayer().add(square); }
protected void addInfo (CanvasImage image, float cx, float y) { TextLayout ilayout = graphics().layoutText(image.width() + "x" + image.height(), infoFormat); CanvasImage iimage = graphics().createImage(ilayout.width(), ilayout.height()); iimage.canvas().setFillColor(0xFF000000).fillText(ilayout, 0, 0); graphics().rootLayer().addAt(graphics().createImageLayer(iimage), cx - iimage.width()/2, y); }
@Override public void init() { float x = 50; final Sound fanfare = loadSound("sounds/fanfare"); x = addButton("Play Fanfare", new Runnable() { public void run() { fanfare.play(); addAction("Played Fanfare."); } }, x, 100); Sound lfanfare = loadSound("sounds/fanfare"); lfanfare.setLooping(true); x = addLoopButtons("Fanfare", lfanfare, x); final Sound bling = loadSound("sounds/bling"); x = addButton("Play Bling", new Runnable() { public void run() { bling.play(); addAction("Played Bling."); } }, x, 100); Sound lbling = loadSound("sounds/bling"); lbling.setLooping(true); x = addLoopButtons("Bling", lbling, x); graphics().rootLayer().addAt(graphics().createImageLayer(_actionsImage), 50, 150); }
protected ImageLayer createLabel(String text, GroupLayer parent, int fg, int bg, float x, float y, float padding) { TextLayout layout = graphics().layoutText(text, baseFormat); float twidth = layout.width() + padding * 2; float theight = layout.height() + padding * 2; CanvasImage image = graphics().createImage(twidth, theight); if (bg != 0) { image.canvas().setFillColor(bg); image.canvas().fillRect(0, 0, twidth, theight); } image.canvas().setFillColor(fg); image.canvas().fillText(layout, padding, padding); ImageLayer imageLayer = graphics().createImageLayer(image); imageLayer.setTranslation(x, y); parent.add(imageLayer); return imageLayer; }
@Override public void init() { String text = "The quick brown fox jumped over the lazy dog."; TextFormat format = new TextFormat(). withFont(graphics().createFont("Helvetica", Font.Style.PLAIN, 18)); TextBlock block = new TextBlock(graphics().layoutText(text, format, new TextWrap(100))); float x = 5; for (float scale : new float[] { 1f, 2f, 3f }) { float swidth = block.bounds.width() * scale, sheight = block.bounds.height() * scale; CanvasImage image = graphics().createImage(swidth, sheight); image.canvas().setStrokeColor(0xFFFFCCCC).strokeRect(0, 0, swidth-0.5f, sheight-0.5f); image.canvas().scale(scale, scale); image.canvas().setFillColor(0xFF000000); block.fill(image.canvas(), TextBlock.Align.RIGHT, 0, 0); graphics().rootLayer().addAt(graphics().createImageLayer(image), x, 5); addInfo(image, x + swidth/2, sheight + 10); x += swidth + 5; } }