com.kotcrab.vis.ui.widget.VisLabel Java Examples

The following examples show how to use com.kotcrab.vis.ui.widget.VisLabel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExpandEditTextButton.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
public ExpandEditTextButton(String text, Style style) {
    super(style);
    this.style = style;

    label = new VisLabel(text, style.labelStyle);
    label.setAlignment(Align.left);
    label.setEllipsis(true);

    labelCell = add(label).growX().left().width(new LabelCellWidthValue());

    if (style.expandIcon != null) {
        Image image = new Image(style.expandIcon);
        image.setScaling(Scaling.none);

        expandIconCell = add(image).padLeft(4f);
    }
}
 
Example #2
Source File: TooltipLmlAttribute.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
@Override
public void process(final LmlParser parser, final LmlTag tag, final Actor actor, final String rawAttributeData) {
    VisLabel lblText = new VisLabel(parser.parseString(rawAttributeData, actor));
    lblText.setAlignment(Align.center);
    boolean needLineWrap = lblText.getPrefWidth() > LINE_WRAP_THRESHOLD;
    if (needLineWrap) {
        lblText.setWrap(true);
    }

    final Tooltip tooltip = new Tooltip();
    tooltip.clearChildren(); // Removing empty cell with predefined paddings.
    Cell<VisLabel> tooltipCell = tooltip.add(lblText).center().pad(0f, 4f, 2f, 4f);
    if (needLineWrap) { tooltipCell.width(LINE_WRAP_THRESHOLD); }
    tooltip.pack();
    tooltip.setTarget(actor);
}
 
Example #3
Source File: TestGenerateDisabledImage.java    From vis-ui with Apache License 2.0 6 votes vote down vote up
private void addVisWidgets () {
	Drawable icon = VisUI.getSkin().getDrawable("icon-folder");
	VisImageButton normal = new VisImageButton(icon);
	VisImageButton disabled = new VisImageButton(icon);
	disabled.setGenerateDisabledImage(true);
	disabled.setDisabled(true);
	add(new VisLabel("VisImageButton normal"));
	add(normal).row();
	add(new VisLabel("VisImageButton disabled"));
	add(disabled).row();

	VisImageTextButton normalText = new VisImageTextButton("text", icon);
	VisImageTextButton disabledText = new VisImageTextButton("text", icon);
	disabledText.setGenerateDisabledImage(true);
	disabledText.setDisabled(true);
	add(new VisLabel("VisImageTextButton normal"));
	add(normalText).row();
	add(new VisLabel("VisImageTextButton disabled"));
	add(disabledText).padBottom(3f).row();
}
 
Example #4
Source File: TestTree.java    From vis-ui with Apache License 2.0 6 votes vote down vote up
private void addVisWidgets () {
	VisTree tree = new VisTree();
	TestNode item1 = new TestNode(new VisLabel("item 1"));
	TestNode item2 = new TestNode(new VisLabel("item 2"));
	TestNode item3 = new TestNode(new VisLabel("item 3"));

	item1.add(new TestNode(new VisLabel("item 1.1")));
	item1.add(new TestNode(new VisLabel("item 1.2")));
	item1.add(new TestNode(new VisLabel("item 1.3")));

	item2.add(new TestNode(new VisLabel("item 2.1")));
	item2.add(new TestNode(new VisLabel("item 2.2")));
	item2.add(new TestNode(new VisLabel("item 2.3")));

	item3.add(new TestNode(new VisLabel("item 3.1")));
	item3.add(new TestNode(new VisLabel("item 3.2")));
	item3.add(new TestNode(new VisLabel("item 3.3")));

	item1.setExpanded(true);

	tree.add(item1);
	tree.add(item2);
	tree.add(item3);

	add(tree).expand().fill();
}
 
Example #5
Source File: MPQViewer.java    From riiablo with Apache License 2.0 6 votes vote down vote up
private void treeify(Trie<String, Node> nodes, Node root, String path) {
  Node parent = root;
  String[] parts = path.split("\\\\");
  StringBuilder builder = new StringBuilder(path.length());
  for (String part : parts) {
    if (part.isEmpty()) {
      break;
    }

    builder.append(part).append("\\");
    String partPath = builder.toString();
    Node node = nodes.get(partPath);
    if (node == null) {
      node = new BaseNode(new VisLabel(part));
      nodes.put(partPath, node);
      parent.add(node);
    }

    parent = node;
  }
}
 
Example #6
Source File: TestButtonBar.java    From vis-ui with Apache License 2.0 6 votes vote down vote up
public TestButtonBar () {
	super("buttonbar");

	addCloseButton();
	closeOnEscape();

	TableUtils.setSpacingDefaults(this);
	columnDefaults(0).left();

	add(new VisLabel("Windows: "));
	add(createTable(ButtonBar.WINDOWS_ORDER)).expand().fill();
	row();

	add(new VisLabel("Linux: "));
	add(createTable(ButtonBar.LINUX_ORDER)).expand().fill();
	row();

	add(new VisLabel("Mac: "));
	add(createTable(ButtonBar.OSX_ORDER)).expand().fill();
	row();

	pack();
	setPosition(300, 245);
}
 
Example #7
Source File: BasicColorPicker.java    From vis-ui with Apache License 2.0 6 votes vote down vote up
private VisTable createHexTable () {
	VisTable table = new VisTable(true);
	table.add(new VisLabel(HEX.get()));
	table.add(hexField = new VisValidatableTextField("00000000")).width(HEX_FIELD_WIDTH * sizes.scaleFactor);
	table.row();

	hexField.setMaxLength(HEX_COLOR_LENGTH);
	hexField.setProgrammaticChangeEvents(false);
	hexField.setTextFieldFilter(new TextFieldFilter() {
		@Override
		public boolean acceptChar (VisTextField textField, char c) {
			return Character.isDigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
		}
	});

	hexField.addListener(new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			if (hexField.getText().length() == (allowAlphaEdit ? HEX_COLOR_LENGTH_WITH_ALPHA : HEX_COLOR_LENGTH)) {
				setColor(Color.valueOf(hexField.getText()), false);
			}
		}
	});

	return table;
}
 
Example #8
Source File: TestSplitPane.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
private void addVisWidgets () {
	VisLabel label = new VisLabel("Lorem \nipsum \ndolor \nsit \namet");
	VisLabel label2 = new VisLabel("Consectetur \nadipiscing \nelit");
	VisTable table = new VisTable(true);
	VisTable table2 = new VisTable(true);

	table.add(label);
	table2.add(label2);

	VisSplitPane splitPane = new VisSplitPane(table, table2, vertical);
	add(splitPane).fill().expand();
}
 
Example #9
Source File: TestMultiSplitPane.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
private void addVisWidgets () {
	VisLabel label = new VisLabel("Label #1");
	VisLabel label2 = new VisLabel("Label #2");
	VisLabel label3 = new VisLabel("Label #3");

	MultiSplitPane splitPane = new MultiSplitPane(vertical);
	splitPane.setWidgets(label, label2, label3);
	add(splitPane).fill().expand();
}
 
Example #10
Source File: TestTabbedPane.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
public TestTab (String title) {
	super(false, true);
	this.title = title;

	content = new VisTable();
	content.add(new VisLabel(title));
}
 
Example #11
Source File: ColorChannelWidget.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
public ColorChannelWidget (PickerCommons commons, String label, int mode, int maxValue, final ChannelBar.ChannelBarListener listener) {
	super(true);
	this.commons = commons;

	this.style = commons.style;
	this.sizes = commons.sizes;
	this.mode = mode;
	this.maxValue = maxValue;

	barListener = new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			value = bar.getValue();
			listener.updateFields();
			inputField.setValue(value);
		}
	};

	add(new VisLabel(label)).width(10 * sizes.scaleFactor).center();
	add(inputField = new ColorInputField(maxValue, new ColorInputFieldListener() {
		@Override
		public void changed (int newValue) {
			value = newValue;
			listener.updateFields();
			bar.setValue(newValue);
		}
	})).width(BasicColorPicker.FIELD_WIDTH * sizes.scaleFactor);
	add(bar = createBarImage()).size(BasicColorPicker.BAR_WIDTH * sizes.scaleFactor, BasicColorPicker.BAR_HEIGHT * sizes.scaleFactor);
	bar.setChannelBarListener(listener);

	inputField.setValue(0);
}
 
Example #12
Source File: SimpleListAdapter.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
@Override
protected VisTable createView (ItemT item) {
	VisTable table = new VisTable();
	table.left();
	table.add(new VisLabel(item.toString()));
	return table;
}
 
Example #13
Source File: TextFieldWithLabel.java    From Mundus with Apache License 2.0 5 votes vote down vote up
public TextFieldWithLabel(String labelText, int width) {
    super();
    this.width = width;
    textField = new VisTextField();
    label = new VisLabel(labelText);
    setupUI();
}
 
Example #14
Source File: MPQViewer.java    From riiablo with Apache License 2.0 5 votes vote down vote up
private void sort(Node root) {
  if (root.getChildren().size == 0) {
    return;
  }

  root.getChildren().sort(new Comparator<Node>() {
    @Override
    public int compare(Node o1, Node o2) {
      boolean o1Empty = o1.getChildren().size == 0;
      boolean o2Empty = o2.getChildren().size == 0;
      if (!o1Empty && o2Empty) {
        return -1;
      } else if (o1Empty && !o2Empty) {
        return 1;
      }

      VisLabel l1 = (VisLabel) o1.getActor();
      VisLabel l2 = (VisLabel) o2.getActor();
      return StringUtils.compare(l1.getText().toString().toLowerCase(), l2.getText().toString().toLowerCase());
    }
  });

  root.updateChildren();
  for (Node child : (Array<Node>) root.getChildren()) {
    sort(child);
  }
}
 
Example #15
Source File: MessageToast.java    From vis-ui with Apache License 2.0 4 votes vote down vote up
public MessageToast (String message) {
	super();
	add(new VisLabel(message)).left().row();
	add(linkLabelTable).right();
}
 
Example #16
Source File: MPQViewer.java    From riiablo with Apache License 2.0 4 votes vote down vote up
private void readMPQs() {
  if (fileTreeNodes == null) {
    fileTreeNodes = new PatriciaTrie<>();
    fileTreeCofNodes = new PatriciaTrie<>();
  } else {
    fileTreeNodes.clear();
    fileTreeCofNodes.clear();
  }

  BufferedReader reader = null;
  try {
    //if (options_useExternalList.isChecked()) {
      reader = Gdx.files.internal(ASSETS + "(listfile)").reader(4096);
    //} else {
    //  try {
    //    reader = new BufferedReader(new InputStreamReader((new ByteArrayInputStream(mpq.readBytes("(listfile)")))));
    //  } catch (Throwable t) {
    //    reader = Gdx.files.internal(ASSETS + "(listfile)").reader(4096);
    //  }
    //}

    Node<Node, Object, Actor> root = new BaseNode(new VisLabel("root"));
    final boolean checkExisting = options_checkExisting.isChecked();

    String fileName;
    while ((fileName = reader.readLine()) != null) {
      if (checkExisting && !Riiablo.mpqs.contains(fileName)) {
        continue;
      }

      String path = FilenameUtils.getPathNoEndSeparator(fileName).toLowerCase();
      treeify(fileTreeNodes, root, path);

      final MPQFileHandle handle = (MPQFileHandle) Riiablo.mpqs.resolve(fileName);
      VisLabel label = new VisLabel(FilenameUtils.getName(fileName));
      final Node node = new BaseNode(label);
      node.setValue(handle);
      label.addListener(new ClickListener(Input.Buttons.RIGHT) {
        @Override
        public void clicked(InputEvent event, float x, float y) {
          showPopmenu(node, handle);
        }
      });

      String key = fileName.toLowerCase();
      fileTreeNodes.put(key, node);
      if (FilenameUtils.isExtension(key, "cof")) {
        key = FilenameUtils.getBaseName(key);
        fileTreeCofNodes.put(key, node);
      }
      if (path.isEmpty()) {
        root.add(node);
      } else {
        fileTreeNodes.get(path + "\\").add(node);
      }
    }

    sort(root);
    fileTree.clearChildren();
    for (Node child : root.getChildren()) {
      fileTree.add(child);
    }

    fileTree.layout();
    fileTreeFilter.clearText();
  } catch (IOException e) {
    throw new GdxRuntimeException("Failed to read list file.", e);
  } finally {
    StreamUtils.closeQuietly(reader);
  }
}
 
Example #17
Source File: TestBusyBar.java    From vis-ui with Apache License 2.0 4 votes vote down vote up
private void addVisWidgets () {
	BusyBar busyBar = new BusyBar();
	add(busyBar).top().space(0).growX().row();
	add(new VisLabel("Working...", Align.center)).grow().center();
}
 
Example #18
Source File: MessageToast.java    From gdx-texture-packer-gui with Apache License 2.0 4 votes vote down vote up
public MessageToast(String message) {
	super();
	add(new VisLabel(message)).left().row();
	add(linkLabelTable).right();
}
 
Example #19
Source File: TestFlowGroup.java    From vis-ui with Apache License 2.0 4 votes vote down vote up
public TestFlowGroup () {
		super("flow groups");

		TableUtils.setSpacingDefaults(this);
		columnDefaults(0).left();

		setResizable(true);
		addCloseButton();
		closeOnEscape();

		WidgetGroup group = new VerticalFlowGroup(2);

		String lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi luctus magna sit amet tellus egestas tincidunt. " +
				"Morbi tempus eleifend dictum. Nunc ex nisl, dignissim eget gravida vel, rutrum a nibh. Fusce congue odio ac elit " +
				"rhoncus rutrum. Donec nec lectus leo. Phasellus et consectetur ante. Cras vel consectetur mauris, sed semper lectus. ";
		String[] parts = lorem.split(" ");
		for (String part : parts) {
			group.addActor(new VisLabel(part));
		}

//		group.addActor(new VisLabel("Lorem ipsum"));
//		group.addActor(new VisLabel("dolor sit"));
//		group.addActor(new VisLabel("amet"));
//		group.addActor(new VisLabel("a\nb\nc"));
//		group.addActor(new VisLabel("Lorem ipsum"));
//		group.addActor(new VisLabel("dolor sit"));
//		group.addActor(new VisLabel("amet"));
//		group.addActor(new VisLabel("a\nb\nc"));
//		group.addActor(new VisLabel("Lorem ipsum"));
//		group.addActor(new VisLabel("dolor sit"));
//		group.addActor(new VisLabel("amet"));
//		group.addActor(new VisLabel("a\nb\nc"));

		VisScrollPane scrollPane = new VisScrollPane(group);
		scrollPane.setFadeScrollBars(false);
		scrollPane.setFlickScroll(false);
		scrollPane.setOverscroll(false, false);
		scrollPane.setScrollingDisabled(group instanceof HorizontalFlowGroup, group instanceof VerticalFlowGroup);
		add(scrollPane).grow();

		setSize(300, 150);
		centerWindow();
	}
 
Example #20
Source File: ExpandEditTextButton.java    From gdx-texture-packer-gui with Apache License 2.0 4 votes vote down vote up
public Style(Drawable up, Drawable down, Drawable checked, VisLabel.LabelStyle labelStyle) {
    super(up, down, checked);
    this.labelStyle = labelStyle;
}
 
Example #21
Source File: ExpandEditTextButton.java    From gdx-texture-packer-gui with Apache License 2.0 4 votes vote down vote up
public VisLabel getLabel() {
    return label;
}