Example #1
0
  public String le() {
    if (celulaSelecionada == null || celulaSelecionada.getValor() == null) {
      return "";
    }

    return celulaSelecionada.getValor();
  }
Example #2
0
  public Fita() {

    getStylesheets().addAll("app.css");

    setPrefHeight(200);
    setMaxHeight(Control.USE_PREF_SIZE);
    setFitToHeight(true);

    celulaContainer = new HBox();
    celulaContainer.setPadding(new Insets(3, 3, 3, 3));
    setContent(celulaContainer);

    celulas = new ArrayList<>();
    for (int i = 0; i < 50; i++) {
      Celula celula = new Celula();
      celulas.add(celula);
      celulaContainer.getChildren().add(celula);
    }

    Celula primeiraCelula = celulas.get(0);

    primeiraCelula.setEditavel(false);
    primeiraCelula.setValor(">");

    selecionarCelula(primeiraCelula);
  }
 public Object retiraPrimeiro() throws Exception {
   if (this.vazia()) throw new Exception("Erro: Lista vazia");
   Celula aux = this.primeiro;
   Celula q = aux.prox;
   Object item = q.item;
   aux.prox = q.prox;
   if (aux.prox == null) this.ultimo = aux;
   return item;
 }
 public Object retira(Object chave) throws Exception {
   if (this.vazia() || (chave == null)) throw new Exception("Erro: Lista vazia ou chave invalida");
   Celula aux = this.primeiro;
   while (aux.prox != null && !aux.prox.item.equals(chave)) aux = aux.prox;
   if (aux.prox == null) return null; // @{\it Chave n\~ao encontrada}@
   Celula q = aux.prox;
   Object item = q.item;
   aux.prox = q.prox;
   if (aux.prox == null) this.ultimo = aux;
   return item;
 }
Example #5
0
  public void escreve(String valor) {
    if (celulaSelecionada == null) {
      return;
    }

    celulaSelecionada.setValor(valor);
  }
Example #6
0
  private void selecionarCelula(Celula celula) {

    if (celulaSelecionada != null) {
      celulaSelecionada.setSelecionada(false);
    }

    celulaSelecionada = celula;
    celulaSelecionada.setSelecionada(true);

    double h = getContent().getBoundsInLocal().getWidth();
    double y =
        (celulaSelecionada.getBoundsInParent().getMaxX()
                + celulaSelecionada.getBoundsInParent().getMinX())
            / 2.0;
    double v = getViewportBounds().getWidth();
    setHvalue(getHmax() * ((y - 0.5 * v) / (h - v)));
  }