use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.
the class ZyNodeBuilder method addCommentLines.
/**
* Creates line content objects for a single comment string. If necessary, the string comment is
* broken into several lines.
*
* @param content The label content where the line content objects are added.
* @param comments The comment string to add to the label content.
* @param color The color used for the comment line.
* @param object The object to associate with the comment lines.
*/
private static void addCommentLines(final ZyLabelContent content, final List<IComment> comments, final Color color, final Object object) {
Preconditions.checkNotNull(content, "IE01180: Content argument can't be null");
Preconditions.checkNotNull(comments, "IE01181: Comment argument can not be null");
Preconditions.checkNotNull(color, "IE01183: Color argument can not be null");
Preconditions.checkNotNull(object, "IE01191: Object argument can not be null");
for (final IComment comment : comments) {
final CommentContainer currentCommentContainer = new CommentContainer(comment);
for (final String commentString : currentCommentContainer.getCommentingString()) {
final ZyLineContent lineContent = new ZyLineContent(commentString, ITALIC_FONT, null);
lineContent.setTextColor(Color.BLACK);
lineContent.setObject(0, commentString.length(), object);
if (commentString.equals(currentCommentContainer.getCommentingString().get(0))) {
lineContent.setTextColor(0, currentCommentContainer.getCommentUserNameLength(), currentCommentContainer.getCommentColor());
}
content.addLineContent(lineContent);
}
}
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.
the class ZyNodeBuilder method addTagLines.
/**
* Adds the name of a tag to the content of a label.
*
* @param content The label content where the line content object is added.
* @param node The node that provides the tags.
* @param prefix The prefix that is written in front of all tag lines.
* @param color The color used for the tag line.
*/
private static void addTagLines(final ZyLabelContent content, final INaviViewNode node, final String prefix, final Color color) {
Preconditions.checkNotNull(content, "IE00918: Content argument can't be null");
Preconditions.checkNotNull(node, "IE00919: Node argument can't be null");
Preconditions.checkNotNull(color, "IE00920: Color argument can't be null");
final Iterator<CTag> it = node.getTagsIterator();
while (it.hasNext()) {
final CTag tag = it.next();
if (!"".equals(tag.getName())) {
final ZyLineContent lineComment = new ZyLineContent(prefix + tag.getName(), null);
lineComment.setTextColor(color);
lineComment.setFont(ITALIC_BOLD_FONT);
content.addLineContent(lineComment);
}
}
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.
the class CAbstractKeyBehavior method getMultilineComment.
protected String getMultilineComment(final int lineYPos, final String changedLine) {
final StringBuilder commentText = new StringBuilder();
final int nonCommentLine = m_labelContent.getNonPureCommentLineIndexOfModelAt(lineYPos);
final int firstModelLine = m_labelContent.getFirstLineIndexOfModelAt(lineYPos);
final int lastModelLine = m_labelContent.getLastLineIndexOfModelAt(lineYPos);
int startIndex = isAboveLineComment(lineYPos) ? firstModelLine : nonCommentLine;
int endIndex = isAboveLineComment(lineYPos) ? nonCommentLine - 1 : lastModelLine;
if (nonCommentLine == -1) {
startIndex = firstModelLine;
endIndex = lastModelLine;
}
for (int index = startIndex; index <= endIndex; ++index) {
if (index == lineYPos) {
commentText.append(changedLine);
} else {
final ZyLineContent curLineContent = m_labelContent.getLineContent(index);
final String lineText = getSingleLineCommentText(curLineContent);
commentText.append(lineText);
}
}
return commentText.toString().equals("") ? changedLine : commentText.toString();
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.
the class CAbstractKeyBehavior method isDeleteableSelection.
protected boolean isDeleteableSelection() {
final int mouseStartY = Math.min(getCaretMousePressedY(), getCaretMouseReleasedY());
final int mouseEndY = Math.max(getCaretMousePressedY(), getCaretMouseReleasedY());
final int caretStartX = Math.min(getCaretStartPosX(), getCaretEndPosX());
final int caretEndX = Math.max(getCaretStartPosX(), getCaretEndPosX());
final ZyLineContent firstLineContent = getLineContent(mouseStartY);
final ZyLineContent lastLineContent = getLineContent(mouseEndY);
final IZyEditableObject firstEditObject = firstLineContent.getLineFragmentObjectAt(caretStartX);
final IZyEditableObject lastEditObject = firstLineContent.getLineFragmentObjectAt(caretEndX);
if (firstLineContent.getLineObject() != lastLineContent.getLineObject()) {
return false;
}
if (isComment(caretStartX, mouseStartY)) {
if (mouseEndY > mouseStartY) {
final int noneCommentLine = m_labelContent.getNonPureCommentLineIndexOfModelAt(mouseStartY);
if (noneCommentLine != -1) {
if ((mouseStartY < noneCommentLine) && (mouseEndY >= noneCommentLine)) {
return false;
} else if ((mouseStartY >= noneCommentLine) && (mouseEndY < noneCommentLine)) {
return false;
}
}
}
} else {
if ((firstEditObject != lastEditObject) || ((firstEditObject == null) && (lastEditObject == null))) {
return false;
}
}
return true;
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.
the class CAbstractKeyBehavior method getNextModelLineContent.
protected ZyLineContent getNextModelLineContent(final int lineYPos) {
final ZyLineContent lineContent = m_labelContent.getLineContent(lineYPos);
final IZyEditableObject lineObject = lineContent.getLineObject();
for (int index = lineYPos + 1; index < m_labelContent.getLineCount(); ++index) {
final ZyLineContent nextLineContent = m_labelContent.getLineContent(index);
if (nextLineContent == null) {
return null;
}
final IZyEditableObject nextLineObject = nextLineContent.getLineObject();
if ((lineObject != nextLineObject) && !nextLineObject.isPlaceholder()) {
return nextLineContent;
}
}
return null;
}
Aggregations