use of org.antlr.works.ate.gutter.ATEGutterItem in project antlrworks by antlr.
the class ATEGutter method paintItems.
private void paintItems(Graphics2D g, Rectangle clip) {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(Color.red);
for (ItemInfo info : items) {
Rectangle r = info.r;
if (clip.intersects(r)) {
ATEGutterItem item = info.item;
int x = r.x;
for (int t : item.getItemTypes()) {
ImageIcon i = item.getItemIcon(t);
g.drawImage(i.getImage(), x, r.y, null);
x += i.getIconWidth();
}
}
}
}
use of org.antlr.works.ate.gutter.ATEGutterItem in project antlrworks by antlr.
the class ATEGutter method updateInfo.
public void updateInfo(Rectangle clip) {
/** Make sure we are only updating objects in the current visible range
*
*/
int startIndex = textEditor.textPane.viewToModel(new Point(clip.x, clip.y));
int endIndex = textEditor.textPane.viewToModel(new Point(clip.x + clip.width, clip.y + clip.height));
items.clear();
if (textEditor.gutterColumnsManager != null) {
ATEGutterColumnManager manager = textEditor.gutterColumnsManager;
int offsetX = offsetForLineNumber;
for (String column : manager.getColumns()) {
for (ATEGutterItem item : manager.getGutterItems(column)) {
int index = item.getItemIndex();
if (index >= startIndex && index <= endIndex) {
int y = getLineYPixelPosition(item.getItemIndex());
int width = item.getItemWidth();
int height = item.getItemHeight();
Rectangle r = new Rectangle(offsetX, y - height / 2, width, height);
this.items.add(new ItemInfo(item, r));
}
}
offsetX += manager.getColumnWidth(column);
}
}
foldingInfos.clear();
if (textEditor.foldingManager != null) {
List<ATEFoldingEntity> entities = textEditor.foldingManager.getFoldingEntities();
for (ATEFoldingEntity entity : entities) {
int entityStartIndex = entity.foldingEntityGetStartIndex();
int entityEndIndex = entity.foldingEntityGetEndIndex();
if (!(entityStartIndex > endIndex || entityEndIndex < startIndex)) {
int top_y = getLineYPixelPosition(entity.foldingEntityGetStartIndex());
int bottom_y = getLineYPixelPosition(entity.foldingEntityGetEndIndex());
Point top = new Point(getWidth() - getOffsetFromText(), top_y);
Point bottom = new Point(getWidth() - getOffsetFromText(), bottom_y);
foldingInfos.add(new FoldingInfo(entity, top, bottom));
}
}
}
}
use of org.antlr.works.ate.gutter.ATEGutterItem in project antlrworks by antlr.
the class ATEGutter method getItemTypeAtLocation.
private int getItemTypeAtLocation(ItemInfo ii, Point location) {
ATEGutterItem item = ii.item;
int width = item.getItemWidth();
for (int i = item.getItemTypes().size() - 1; i >= 0; i--) {
int t = item.getItemTypes().get(i);
width -= item.getItemIcon(t).getIconWidth();
if (location.x > ii.r.x + width) {
return t;
}
}
return -1;
}
use of org.antlr.works.ate.gutter.ATEGutterItem in project antlrworks by antlr.
the class EditorGutterColumnManager method getGutterItems.
public List<ATEGutterItem> getGutterItems(String column) {
if (column.equals(RULES)) {
List<ATEGutterItem> items = new ArrayList<ATEGutterItem>();
List<ElementRule> rules = window.getGrammarEngine().getRules();
if (rules != null) {
for (ElementRule r : rules) {
items.add(r);
}
}
return items;
} else {
List<Integer> sortedKeys = new ArrayList<Integer>(breakpoints.keySet());
Collections.sort(sortedKeys);
List<ATEGutterItem> sortedItems = new ArrayList<ATEGutterItem>();
for (Integer k : sortedKeys) {
sortedItems.add(breakpoints.get(k));
}
return sortedItems;
}
}
use of org.antlr.works.ate.gutter.ATEGutterItem in project antlrworks by antlr.
the class EditorGutterColumnManager method getColumnWidth.
public int getColumnWidth(String column) {
int width = 0;
if (column.equals(BREAKPOINTS) && breakpoints.isEmpty()) {
width = DEFAULT_NO_BREAKPOINTS_WIDTH;
}
List<ATEGutterItem> items = getGutterItems(column);
for (ATEGutterItem item : items) {
width = Math.max(width, item.getItemWidth());
}
return width;
}
Aggregations