use of com.kotcrab.vis.ui.widget.VisImage in project gdx-graph by MarcinSc.
the class ValueColorBoxProducer method createValuePart.
private GraphBoxPartImpl createValuePart(String value) {
Color color = Color.valueOf(value);
final TextureRegionDrawable drawable = new TextureRegionDrawable(WhitePixel.sharedInstance.texture);
BaseDrawable baseDrawable = new BaseDrawable(drawable) {
@Override
public void draw(Batch batch, float x, float y, float width, float height) {
drawable.draw(batch, x, y, width, height);
}
};
baseDrawable.setMinSize(20, 20);
final VisImage image = new VisImage(baseDrawable);
image.setColor(color);
final ColorPicker picker = new ColorPicker(new ColorPickerAdapter() {
@Override
public void finished(Color newColor) {
image.setColor(newColor);
image.fire(new GraphChangedEvent(false, true));
}
});
picker.setColor(color);
image.addListener(new ClickListener(Input.Buttons.LEFT) {
@Override
public void clicked(InputEvent event, float x, float y) {
// displaying picker with fade in animation
image.getStage().addActor(picker.fadeIn());
}
});
VisTable table = new VisTable();
table.add(new VisLabel("Color")).growX();
table.add(image);
table.row();
GraphBoxPartImpl colorPart = new GraphBoxPartImpl(table, new GraphBoxPartImpl.Callback() {
@Override
public void serialize(JsonValue object) {
object.addChild("color", new JsonValue(image.getColor().toString()));
}
}) {
@Override
public void dispose() {
picker.dispose();
}
};
colorPart.setOutputConnector(GraphBoxOutputConnector.Side.Right, configuration.getNodeOutputs().get("value"));
return colorPart;
}
Aggregations