2018-09-02 13:36:49 +02:00
|
|
|
package it.cavallium.warppi.gui.expression.blocks;
|
2017-03-03 23:06:43 +01:00
|
|
|
|
2019-02-27 23:29:03 +01:00
|
|
|
import it.cavallium.warppi.device.display.DisplayOutputDevice;
|
2018-09-02 13:36:49 +02:00
|
|
|
import it.cavallium.warppi.gui.expression.Caret;
|
2018-10-04 23:39:19 +02:00
|
|
|
import it.cavallium.warppi.gui.expression.InputContext;
|
2018-09-02 13:36:49 +02:00
|
|
|
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
|
|
|
import it.cavallium.warppi.math.MathContext;
|
|
|
|
import it.cavallium.warppi.math.parser.features.FeatureChar;
|
|
|
|
import it.cavallium.warppi.math.parser.features.interfaces.Feature;
|
2018-10-04 08:49:11 +02:00
|
|
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
2017-03-03 23:06:43 +01:00
|
|
|
|
|
|
|
public class BlockChar extends Block {
|
2017-04-10 22:50:43 +02:00
|
|
|
|
2017-03-03 23:06:43 +01:00
|
|
|
private final char ch;
|
2017-04-10 22:50:43 +02:00
|
|
|
|
2018-09-22 11:17:30 +02:00
|
|
|
public BlockChar(final char ch) {
|
2017-03-03 23:06:43 +01:00
|
|
|
this.ch = ch;
|
|
|
|
recomputeDimensions();
|
|
|
|
}
|
|
|
|
|
2018-10-09 23:51:42 +02:00
|
|
|
/**
|
|
|
|
* Copy
|
|
|
|
* @param b
|
|
|
|
* @param ic
|
|
|
|
*/
|
|
|
|
protected BlockChar(final TreeContainer parent, final BlockChar b, InputContext ic) {
|
|
|
|
super(parent, b);
|
|
|
|
this.ch = b.ch;
|
2018-10-04 23:39:19 +02:00
|
|
|
}
|
|
|
|
|
2017-03-03 23:06:43 +01:00
|
|
|
@Override
|
2019-02-27 23:29:03 +01:00
|
|
|
public void draw(final DisplayOutputDevice ge, final Renderer r, final int x, final int y, final Caret caret) {
|
2017-03-03 23:06:43 +01:00
|
|
|
BlockContainer.getDefaultFont(small).use(ge);
|
|
|
|
r.glColor(BlockContainer.getDefaultColor());
|
|
|
|
r.glDrawCharLeft(x, y, ch);
|
|
|
|
}
|
|
|
|
|
2017-03-26 22:44:09 +02:00
|
|
|
@Override
|
2018-09-22 11:17:30 +02:00
|
|
|
public boolean putBlock(final Caret caret, final Block newBlock) {
|
2017-03-26 22:44:09 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-09-22 11:17:30 +02:00
|
|
|
public boolean delBlock(final Caret caret) {
|
2017-03-26 22:44:09 +02:00
|
|
|
return false;
|
|
|
|
}
|
2017-04-10 22:50:43 +02:00
|
|
|
|
2017-05-05 22:27:11 +02:00
|
|
|
@Override
|
2018-09-22 11:17:30 +02:00
|
|
|
public BlockReference<?> getBlock(final Caret caret) {
|
2017-05-05 22:27:11 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2017-03-03 23:06:43 +01:00
|
|
|
@Override
|
|
|
|
public void recomputeDimensions() {
|
2017-09-24 18:47:30 +02:00
|
|
|
width = BlockContainer.getDefaultCharWidth(small) - 1;
|
2017-03-03 23:06:43 +01:00
|
|
|
height = BlockContainer.getDefaultCharHeight(small);
|
2017-04-10 22:50:43 +02:00
|
|
|
line = height / 2;
|
2017-03-03 23:06:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-09-22 11:17:30 +02:00
|
|
|
public void setSmall(final boolean small) {
|
2017-03-03 23:06:43 +01:00
|
|
|
this.small = small;
|
|
|
|
recomputeDimensions();
|
|
|
|
}
|
2017-04-10 22:50:43 +02:00
|
|
|
|
2017-03-03 23:06:43 +01:00
|
|
|
public char getChar() {
|
|
|
|
return ch;
|
|
|
|
}
|
|
|
|
|
2017-03-26 22:44:09 +02:00
|
|
|
@Override
|
2017-05-26 22:37:18 +02:00
|
|
|
public int computeCaretMaxBound() {
|
|
|
|
return 0;
|
2017-03-26 22:44:09 +02:00
|
|
|
}
|
|
|
|
|
2017-04-09 22:01:03 +02:00
|
|
|
@Override
|
2018-09-22 11:17:30 +02:00
|
|
|
public Feature toFeature(final MathContext context) {
|
2017-05-26 22:37:18 +02:00
|
|
|
return new FeatureChar(getChar());
|
2017-04-09 22:01:03 +02:00
|
|
|
}
|
|
|
|
|
2018-10-04 08:49:11 +02:00
|
|
|
@Override
|
2018-10-04 09:52:14 +02:00
|
|
|
public ObjectArrayList<Block> getInnerBlocks() {
|
2018-10-04 08:49:11 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2018-10-04 09:52:14 +02:00
|
|
|
@Override
|
2018-10-05 22:09:54 +02:00
|
|
|
public ObjectArrayList<BlockContainer> getInnerContainers() {
|
|
|
|
return null;
|
2018-10-04 09:52:14 +02:00
|
|
|
}
|
|
|
|
|
2018-10-04 23:39:19 +02:00
|
|
|
@Override
|
2018-10-09 23:51:42 +02:00
|
|
|
public BlockChar clone(final TreeContainer parent, InputContext ic) {
|
|
|
|
return new BlockChar(parent, this, ic);
|
2018-10-04 23:39:19 +02:00
|
|
|
}
|
|
|
|
|
2017-03-03 23:06:43 +01:00
|
|
|
}
|