stubs for Tackboard

This commit is contained in:
Autumn Lamonte 2021-12-22 12:11:44 -06:00
parent df9a3af500
commit b83fd92a13
4 changed files with 265 additions and 1 deletions

View file

@ -66,7 +66,7 @@ public class HelpFile {
/**
* The XML factory.
*/
private static DocumentBuilder domBuilder;
private DocumentBuilder domBuilder;
/**
* The map of topics by title.

View file

@ -0,0 +1,97 @@
/*
* Jexer - Java Text User Interface
*
* The MIT License (MIT)
*
* Copyright (C) 2021 Autumn Lamonte
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* @author Autumn Lamonte [AutumnWalksTheLake@gmail.com] Trans Liberation Now
* @version 1
*/
package jexer.tackboard;
import java.util.ArrayList;
import java.util.List;
import jexer.backend.GlyphMaker;
import jexer.backend.Screen;
import jexer.bits.Cell;
/**
* Tackboard maintains a collection of TackboardItems to draw on a Screen.
*
* <p>Each item has a set of X, Y, Z pixel (not text cell) coordinates. The
* coordinate system is right-handed: (0, 0, 0) is the top-left pixel on the
* screen, and positive Z points away from the user.</p>
*
* <p>When draw() is called, all the items will be rendered in descending Z,
* ascending Y, ascending X order (painter's algorithm) onto the cell grid,
* and using transparent pixels. If the Screen's backend does not support
* imagesOverText, then the text of the Cell under transparent images will be
* rendered via GlyphMaker, which might not look ideal if the internal font
* is quite different from the terminal's.</p>
*
* <p>Tackboards were directly inspired by the Visuals (ncvisuals) of <a
* href="https://github.com/dankamongmen/notcurses">notcurses</a>. Jexer's
* performance is unlikely to come close to notcurses, so users requiring
* low-latency pixel-based rendering are recommended to check out
* notcurses.</p>
*/
public class Tackboard {
// ------------------------------------------------------------------------
// Constants --------------------------------------------------------------
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// Variables --------------------------------------------------------------
// ------------------------------------------------------------------------
/**
* The items on this board.
*/
private ArrayList<TackboardItem> items = new ArrayList<TackboardItem>();
// ------------------------------------------------------------------------
// Constructors -----------------------------------------------------------
// ------------------------------------------------------------------------
/**
* Public constructor.
*/
public Tackboard() {
// NOP
}
// ------------------------------------------------------------------------
// Tackboard --------------------------------------------------------------
// ------------------------------------------------------------------------
/**
* Draw everything to the screen.
*
* @param screen the screen to render to
*/
public void draw(final Screen screen) {
// TODO
}
}

View file

@ -0,0 +1,134 @@
/*
* Jexer - Java Text User Interface
*
* The MIT License (MIT)
*
* Copyright (C) 2021 Autumn Lamonte
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* @author Autumn Lamonte [AutumnWalksTheLake@gmail.com] Trans Liberation Now
* @version 1
*/
package jexer.tackboard;
import java.awt.image.BufferedImage;
/**
* This class represents a single item image on the tackboard.
*/
public class TackboardItem implements Comparable<TackboardItem> {
// ------------------------------------------------------------------------
// Constants --------------------------------------------------------------
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// Variables --------------------------------------------------------------
// ------------------------------------------------------------------------
/**
* X pixel coordinate.
*/
private int x = 0;
/**
* Y pixel coordinate.
*/
private int y = 0;
/**
* Z pixel coordinate.
*/
private int z = 0;
// ------------------------------------------------------------------------
// Constructors -----------------------------------------------------------
// ------------------------------------------------------------------------
/**
* Public constructor.
*/
public TackboardItem() {
// NOP
}
// ------------------------------------------------------------------------
// TackboardItem ----------------------------------------------------------
// ------------------------------------------------------------------------
/**
* Comparison check. All fields must match to return true.
*
* @param rhs another TackboardItem instance
* @return true if all fields are equal
*/
@Override
public boolean equals(final Object rhs) {
if (!(rhs instanceof TackboardItem)) {
return false;
}
TackboardItem that = (TackboardItem) rhs;
// TODO
return false;
}
/**
* Hashcode uses all fields in equals().
*
* @return the hash
*/
@Override
public int hashCode() {
int A = 13;
int B = 23;
int hash = A;
hash = (B * hash) + super.hashCode();
return hash;
}
/**
* Comparison operator.
*
* @param that another TackboardItem instance
* @return differences between this.x/y/z and that.x/y/z
*/
public int compareTo(final TackboardItem that) {
if (this.z != that.z) {
return this.z - that.z;
}
if (this.y != that.y) {
return that.y - this.y;
}
return that.x - this.x;
}
/**
* Make human-readable description of this item.
*
* @return displayable String
*/
@Override
public String toString() {
return String.format("(%d, %d, %d)", x, y, z);
}
}

View file

@ -0,0 +1,33 @@
/*
* Jexer - Java Text User Interface
*
* The MIT License (MIT)
*
* Copyright (C) 2021 Autumn Lamonte
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* @author Autumn Lamonte [AutumnWalksTheLake@gmail.com] Trans Liberation Now
* @version 1
*/
/**
* Pixel-based overlays.
*/
package jexer.tackboard;