use of org.yamcs.protobuf.Yamcs.ArchiveTag in project yamcs-studio by yamcs.
the class TagBox method showPopup.
void showPopup(final MouseEvent e) {
if (selectedIndex != -1) {
ArchiveTag selectedTag = tags.get(selectedRow).get(selectedIndex);
tagLabelItem.setText(selectedTag.getName());
editTagPopup.validate();
editTagPopup.show(e.getComponent(), e.getX(), e.getY());
}
}
use of org.yamcs.protobuf.Yamcs.ArchiveTag in project yamcs-studio by yamcs.
the class TagTimeline method paintComponent.
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (image == null) {
image = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics2D big = image.createGraphics();
big.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR));
big.fillRect(0, 0, getWidth(), getHeight());
big.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
for (ArchiveTag at : tags) {
// TODO store these values in a map, rather than calculating all the time
RGB rgb = toRGB(at);
Color bgcolor = new Color(rgb.red, rgb.green, rgb.blue);
int brightness = (int) Math.sqrt(.241 * rgb.red * rgb.red + .691 * rgb.green * rgb.green + .068 * rgb.blue * rgb.blue);
Color fgcolor = (brightness < 130) ? Color.WHITE : Color.BLACK;
big.setColor(bgcolor);
long start = (at.hasStart()) ? at.getStart() : zoom.startInstant;
int x1 = zoom.convertInstantToPixel(start);
long stop = (at.hasStop()) ? at.getStop() : zoom.stopInstant;
int x2 = zoom.convertInstantToPixel(stop);
if (x1 <= 0 && x2 < 0)
continue;
if (x1 < 0)
x1 = 0;
int width = (x2 - x1 <= 1) ? 1 : x2 - x1 - 1;
big.fillRect(x1 - leftDelta, 0, width, getHeight());
big.setColor(fgcolor);
big.setFont(f);
Rectangle2D bounds = f.getStringBounds(at.getName(), big.getFontRenderContext());
if (width > bounds.getWidth()) {
LineMetrics lm = f.getLineMetrics(at.getName(), big.getFontRenderContext());
big.drawString(at.getName(), x1 - leftDelta + 1, (int) lm.getAscent() + 1);
}
big.setColor(Color.DARK_GRAY);
big.drawRect(x1 - leftDelta, 0, width - 1, getHeight() - 1);
}
// border.paintBorder(this, big, 0, 0, getWidth(),getHeight() );
}
g.drawImage(image, 0, 0, this);
}
use of org.yamcs.protobuf.Yamcs.ArchiveTag in project yamcs-studio by yamcs.
the class TagTimeline method time2Tag.
static int time2Tag(List<ArchiveTag> tagList, long t) {
int min = 0;
int max = tagList.size() - 1;
int mid;
while (min <= max) {
mid = (min + max) >> 1;
ArchiveTag atmid = tagList.get(mid);
if (!atmid.hasStart() || atmid.getStart() <= t) {
if (!atmid.hasStop() || atmid.getStop() >= t) {
return mid;
} else {
min = mid + 1;
}
} else {
max = mid - 1;
}
}
return -1;
}
use of org.yamcs.protobuf.Yamcs.ArchiveTag in project yamcs-studio by yamcs.
the class TagBox method redrawTags.
void redrawTags() {
// Draw reverse, so that 'most' tags stick to scale
removeAll();
if (!tags.isEmpty()) {
int row = tags.size() - 1;
Insets in = this.getInsets();
for (ListIterator<List<ArchiveTag>> it = tags.listIterator(tags.size()); it.hasPrevious(); ) {
List<ArchiveTag> lat = it.previous();
TagTimeline tt = new TagTimeline(this, lat, zoom, row--, in.left);
add(tt);
}
}
revalidate();
repaint();
}
use of org.yamcs.protobuf.Yamcs.ArchiveTag in project yamcs-studio by yamcs.
the class TagBox method insertTag.
/**
* insert a tag in tags, in order ensuring no overlap.
*
* @param tag
*/
private void insertTag(ArchiveTag tag) {
boolean inserted = false;
for (List<ArchiveTag> atl : tags) {
int min = 0, max = atl.size() - 1;
while (min <= max) {
int mid = (min + max) >> 1;
ArchiveTag midtag = atl.get(mid);
if (tag.hasStop() && midtag.hasStart() && tag.getStop() < midtag.getStart()) {
max = mid - 1;
} else if (tag.hasStart() && midtag.hasStop() && tag.getStart() > midtag.getStop()) {
min = mid + 1;
} else {
// overlap
break;
}
}
if (min > max) {
atl.add(min, tag);
inserted = true;
break;
}
}
if (!inserted) {
List<ArchiveTag> atl = new ArrayList<>();
atl.add(tag);
tags.add(atl);
}
}
Aggregations