Code Monkey home page Code Monkey logo

torch's People

Contributors

romni avatar thomashakkers avatar thumbnail avatar

Watchers

 avatar  avatar  avatar  avatar

torch's Issues

LineGraph refactor

LineGraph needs to be split up to use a separate data container. My suggestion for this data container is that it's simply a wrapper for List<Double>. Removing the need for getMin and getMax methods on LineGraph itself.

Also it might be possible to combine the two IntStreams into one.

Component: TextBackground

We need a component which can act as an EmptySpace but with a centered text (such as a logo).

A snippet to get started:

package io.leonis.torch.component;

import com.googlecode.lanterna.*;
import com.googlecode.lanterna.gui2.*;
import java.awt.Color;
import lombok.*;

/**
 * The Class TextBackground
 *
 * This class is basically an {@link EmptySpace} with a text on top. The text is a tint brighter
 * than the background color and will be centered based on the current size of the {@link
 * com.googlecode.lanterna.screen.Screen}
 *
 * @author Jeroen de Jong
 */
@Value
@EqualsAndHashCode(callSuper = true)
public final class TextBackground extends AbstractComponent<TextBackground> {

  /**
   * Background label
   */
  private final String text;
  private final TextColor color;

  @Override
  protected ComponentRenderer<TextBackground> createDefaultRenderer() {
    return new ComponentRenderer<TextBackground>() {

      @Override
      public TerminalSize getPreferredSize(final TextBackground component) {
        return component.getParent().getSize();
      }

      @Override
      public void drawComponent(final TextGUIGraphics graphics, final TextBackground component) {
        // TODO this needs some cleanup; also the text should be centered
        graphics.applyThemeStyle(component.getThemeDefinition().getNormal());
        graphics.setBackgroundColor(component.getColor());
        graphics.fill(' ');

        final Label text = new Label(component.getText());
        text.setBackgroundColor(component.getColor());
        final Color brighterColor = component.getColor().toColor().brighter();
        text.setForegroundColor(
            new TextColor.RGB(brighterColor.getRed(), brighterColor.getGreen(),
                brighterColor.getBlue()));
        text.draw(graphics);
      }
    };
  }
}

pressing a special key results in a NPE

The documentation of KeyStroke#getCharacter says:

returns:
Character value of the key pressed, or null if it was a special key

However the result of character is directly compared here:

public boolean onUnhandledKeyStroke(final WindowBasedTextGUI textGUI, final KeyStroke keyStroke) {
if (keyStroke.getCharacter().equals(this.character)) {
textGUI.cycleActiveWindow(this.reverse);
return true;
}

It should be checked whether the KeyStroke#getKeyType is actually a KeyType.Character before checking if KeyStroke#getCharacter is the correct one.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.