/** * Draws the widget * * @param canvas The canvas to draw on. */ public void onDraw(Canvas canvas) { canvas.getRegion(); canvas.drawTexture(sectionTexture, sectionRegion); if (icon != null) { canvas.drawTexture(icon, innerRegion); } if (text != null) { canvas.drawText(text, innerRegion); } if (isSelected) { canvas.drawTexture(selectedTexture, sectionRegion); if (widget != null) { canvas.drawWidget(widget, infoRegion); } } }
canvas.drawTextRaw(textToDraw, lastFont, canvas.getCurrentStyle().getHintTextColor(), canvas.getRegion()); } else { canvas.drawText(textToDraw, canvas.getRegion());
@Override public void onDraw(Canvas canvas) { canvas.drawTexture(texture); BehaviorState status = getState(); String text = getData().displayName + " " + (status != null ? status : ""); if (collapsed) { text += "[+]"; } canvas.drawText(text); if (editor != null) { canvas.addInteractionRegion(moveListener, getData().description); } portList.onDraw(canvas); }
@Override public void onDraw(Canvas canvas) { canvas.drawText(getText()); }
/** * Handles how the {@code UIButton} is drawn. * This is called every frame. * * @param canvas The {@link Canvas} on which this {@code UIButton} is drawn */ @Override public void onDraw(Canvas canvas) { if (image.get() != null) { canvas.drawTexture(image.get()); } canvas.drawText(text.get()); if (isEnabled()) { canvas.addInteractionRegion(interactionListener); } }
@Override public void draw(WorldInfo value, Canvas canvas) { canvas.drawText(value.getCustomTitle()); }
@Override public void onDraw(Canvas canvas) { if (getIcon() != null) { canvas.drawTexture(getIcon()); } else if (getMesh() != null && getMeshTexture() != null) { Quat4f rot = new Quat4f(TeraMath.PI / 6, -TeraMath.PI / 12, 0); canvas.drawMesh(getMesh(), getMeshTexture(), canvas.getRegion(), rot, new Vector3f(), 1.0f); } if (getQuantity() > 1) { canvas.drawText(Integer.toString(getQuantity())); } List<TooltipLine> tooltipLines = tooltip.getList(); if (tooltipLines != null && !tooltipLines.isEmpty()) { canvas.addInteractionRegion(listener); } }
@Override public void draw(DependencyInfo value, Canvas canvas) { canvas.drawText(getString(value), canvas.getRegion()); }
@Override public void draw(T value, Canvas canvas) { // Drawing the icon TextureRegion texture = getTexture(value); if (texture != null) { if (marginTop + texture.getHeight() + marginBottom > canvas.size().y) { // Icon does not fit within the canvas - vertically shrinking it int iconHeight = canvas.size().y - marginTop - marginBottom; canvas.drawTexture(texture, Rect2i.createFromMinAndSize(marginLeft, marginTop, texture.getWidth(), iconHeight)); } else { // Icon fits within the canvas - vertically centering it int iconVerticalPosition = (canvas.size().y - texture.getHeight()) / 2; canvas.drawTexture(texture, Rect2i.createFromMinAndSize(marginLeft, iconVerticalPosition, texture.getWidth(), texture.getHeight())); } } // Drawing the text, adjusting for icon width String text = getString(value); int iconWidth; if (texture != null) { iconWidth = marginLeft + texture.getWidth() + marginRight; } else { iconWidth = 0; } Rect2i textRegion = Rect2i.createFromMinAndSize(iconWidth, 0, canvas.getRegion().width() - iconWidth, canvas.getRegion().height()); canvas.drawText(text, textRegion); }
@Override public void draw(T value, Canvas canvas) { if (wrap) { canvas.drawText(getString(value)); } else { int width = canvas.size().x; Font font = canvas.getCurrentStyle().getFont(); String text = getString(value); if (font.getWidth(text) <= width) { canvas.drawText(text); } else { String shortText = "..."; StringBuilder sb = new StringBuilder(text); while (sb.length() > 0) { shortText = sb.toString() + "..."; if (font.getWidth(shortText) <= width) { break; } sb.setLength(sb.length() - 1); } canvas.drawText(shortText); } } }
@Override public void draw(Biome value, Canvas canvas) { if (value.getId().contains("Core:")) { canvas.setMode("internal"); } else { canvas.setMode("external"); } canvas.drawText(getString(value), canvas.getRegion()); }
/** * Handles how this {@code UIScrollingText} is drawn. * This is called every frame. * * @param canvas The {@link Canvas} on which this {@code UIScrollingText} is drawn */ @Override public void onDraw(Canvas canvas) { if (isScrolling) { updateYValues(canvas); } Font font = canvas.getCurrentStyle().getFont(); int w = canvas.size().x / 2; boolean finished = true; for (Entry<String, Integer> entry : textY.entrySet()) { int y = entry.getValue(); //ignores offsets if (y >= -offsetTop && y <= canvas.size().y - offsetBottom + font.getHeight(entry.getKey())) { String line = entry.getKey(); Rect2i coords = Rect2i.createFromMinAndSize(w - font.getWidth(line) / 2, y, font.getWidth(line), font.getHeight(line)); canvas.drawText(entry.getKey(), coords); } if (y >= -offsetTop) { finished = false; } } if (finished && autoReset) { resetScrolling(); } }
@Override public void draw(ModuleSelectionInfo value, Canvas canvas) { if (value.isStrictVersion()) { canvas.setMode("strict"); } else if (value.isLatestVersion()) { canvas.setMode("latest"); } else { canvas.setMode("invalid"); } canvas.drawText(getString(value), canvas.getRegion()); }
private void drawTicker(Canvas canvas, String part, Binding<Float> value, InteractionListener tickerListener, boolean rightTicker) { canvas.setPart(part); String display = String.format("%." + precision + "f", value.get()); int tickerWidth = canvas.getCurrentStyle().getFont().getWidth(formatString); tickerWidth += canvas.getCurrentStyle().getMargin().getTotalWidth(); sliderWidth = canvas.size().x - tickerWidth * 2; int drawLocation = pixelOffsetFor(value.get(), sliderWidth); if (rightTicker) { drawLocation += tickerWidth; } Rect2i tickerRegion = Rect2i.createFromMinAndSize(drawLocation, 0, tickerWidth, canvas.size().y); try (SubRegion ignored = canvas.subRegion(tickerRegion, false)) { canvas.drawBackground(); canvas.drawText(display); if (isEnabled()) { canvas.addInteractionRegion(tickerListener); } } }
@Override public void draw(ModuleSelectionInfo value, Canvas canvas) { if (isSelectedGameplayModule(value) && value.isValidToSelect()) { canvas.setMode("gameplay"); } else if (value.isSelected() && value.isExplicitSelection()) { canvas.setMode("enabled"); } else if (value.isSelected()) { canvas.setMode("dependency"); } else if (!value.isPresent()) { canvas.setMode("disabled"); } else if (!value.isValidToSelect()) { canvas.setMode("invalid"); } else { canvas.setMode("available"); } canvas.drawText(getString(value), canvas.getRegion()); }
@Override public void onDraw(Canvas canvas) { canvas.setPart(SLIDER); canvas.drawBackground(); canvas.setPart(TICKER); String display = getDisplayText(); int tickerWidth = canvas.getCurrentStyle().getFont().getWidth(display); tickerWidth += canvas.getCurrentStyle().getMargin().getTotalWidth(); sliderWidth = canvas.size().x - tickerWidth; int drawLocation = pixelOffsetFor(getValue(), sliderWidth); Rect2i tickerRegion = Rect2i.createFromMinAndSize(drawLocation, 0, tickerWidth, canvas.size().y); try (SubRegion ignored = canvas.subRegion(tickerRegion, false)) { canvas.drawBackground(); canvas.drawText(display); if (isEnabled()) { canvas.addInteractionRegion(tickerListener); } } }