umlet-2015-06-03_UMLet_v13.3/ 0000755 0001750 0001750 00000000000 12533641120 013223 5 ustar ben ben umlet-2015-06-03_UMLet_v13.3/README.md 0000644 0001750 0001750 00000000576 12533641120 014512 0 ustar ben ben # UMLet
UMLet is an open-source UML tool with a simple user interface: draw UML diagrams fast, export diagrams to eps, pdf, jpg, svg, and clipboard, share diagrams using Eclipse, and create new, custom UML elements.
* Please check out the [Wiki](https://github.com/umlet/umlet/wiki) for frequently asked questions
* Go to http://www.umlet.com to get the latest compiled versions
umlet-2015-06-03_UMLet_v13.3/BaseletElements/ 0000755 0001750 0001750 00000000000 12537353206 016310 5 ustar ben ben umlet-2015-06-03_UMLet_v13.3/BaseletElements/test/ 0000755 0001750 0001750 00000000000 12533641120 017256 5 ustar ben ben umlet-2015-06-03_UMLet_v13.3/BaseletElements/test/com/ 0000755 0001750 0001750 00000000000 12533641120 020034 5 ustar ben ben umlet-2015-06-03_UMLet_v13.3/BaseletElements/test/com/baselet/ 0000755 0001750 0001750 00000000000 12533641120 021453 5 ustar ben ben umlet-2015-06-03_UMLet_v13.3/BaseletElements/test/com/baselet/element/ 0000755 0001750 0001750 00000000000 12533641120 023104 5 ustar ben ben umlet-2015-06-03_UMLet_v13.3/BaseletElements/test/com/baselet/element/sticking/ 0000755 0001750 0001750 00000000000 12533641120 024717 5 ustar ben ben umlet-2015-06-03_UMLet_v13.3/BaseletElements/test/com/baselet/element/sticking/StickablesTest.java 0000644 0001750 0001750 00000010624 12533641120 030511 0 ustar ben ben package com.baselet.element.sticking;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.baselet.control.basics.geom.PointDouble;
import com.baselet.element.sticking.StickingPolygon.StickLine;
public class StickablesTest {
@Test
public void moveLineLeft40_pointLeft40() throws Exception {
PointChange change = calcChange(point(20, 20), vLine(20, 10, 30), -40, 0);
assertPoint(-40, 0, change);
}
@Test
public void moveLineRight40_pointRight40() throws Exception {
PointChange change = calcChange(point(20, 20), vLine(20, 10, 30), 40, 0);
assertPoint(40, 0, change);
}
@Test
public void moveLineUp40_pointUp40() throws Exception {
PointChange change = calcChange(point(20, 20), hLine(10, 30, 20), 0, -40);
assertPoint(0, -40, change);
}
@Test
public void moveLineLeftDown40_pointLeftDown40() throws Exception {
PointChange change = calcChange(point(20, 20), hLine(10, 30, 20), 40, 40);
assertPoint(40, 40, change);
}
@Test
public void moveLineRightDown10_pointRightDown10() throws Exception {
PointChange change = calcChange(point(20, 20), vLine(20, 10, 30), 10, 10);
assertPoint(10, 10, change);
}
@Test
public void resizeLineVertical_pointStaysSame() throws Exception {
PointChange change = calcChange(point(20, 20), vLine(20, 10, 80), vLine(20, 10, 20));
assertPoint(0, 0, change);
}
@Test
public void resizeLineVertical_pointMovesToLowerEnd() throws Exception {
PointChange change = calcChange(point(20, 70), vLine(20, 10, 80), vLine(20, 10, 30));
assertPoint(0, -40, change);
}
@Test
public void resizeLineHorizontal_pointStaysOnLeftEnd() throws Exception {
PointChange change = calcChange(point(20, 50), hLine(20, 150, 50), hLine(100, 150, 50));
assertPoint(80, 0, change);
}
@Test
public void resizeLineVertical_pointStaysOnUpperEnd() throws Exception {
PointChange change = calcChange(point(20, 50), vLine(20, 50, 200), vLine(20, 150, 200));
assertPoint(0, 100, change);
}
@Test
public void resizeLineHorizontal_pointStaysSame() throws Exception {
PointChange change = calcChange(point(20, 50), hLine(20, 150, 50), hLine(100, 150, 50));
assertPoint(80, 0, change);
}
@Test
public void moveHorizontalResizeVertical_pointMovesHorizontalAndStaysSameVertical() throws Exception {
PointChange change = calcChange(point(100, 100), vLine(100, 10, 200), vLine(60, 10, 150));
assertPoint(-40, 0, change);
}
@Test
public void moveHorizontalResizeVertical_pointMovesHorizontalAndMovesToEndVertical() throws Exception {
PointChange change = calcChange(point(50, 50), vLine(50, 10, 200), vLine(100, 10, 30));
assertPoint(50, -20, change);
}
@Test
public void moveVerticalResizeHorizontal_pointMovesVerticalAndStaysSameHorizontal() throws Exception {
PointChange change = calcChange(point(50, 50), hLine(10, 200, 50), hLine(10, 50, 100));
assertPoint(0, 50, change);
}
@Test
public void moveVerticalResizeHorizontal_pointMovesVerticalAndStaysOnLeftEnd() throws Exception {
PointChange change = calcChange(point(50, 50), hLine(10, 200, 50), hLine(10, 20, 100));
assertPoint(-30, 50, change);
}
private void assertPoint(int x, int y, PointChange change) {
assertEquals("correct x movement", x, change.getDiffX());
assertEquals("correct y movement", y, change.getDiffY());
}
private PointChange calcChange(PointDouble point, StickLine oldLine, int xChange, int yChange) {
PointDouble oStart = oldLine.getStart();
PointDouble oEnd = oldLine.getEnd();
return Stickables.calcPointDiffBasedOnStickLineChange(0, point, new StickLineChange(oldLine, line(oStart.getX() + xChange, oStart.getY() + yChange, oEnd.getX() + xChange, oEnd.getY() + yChange)));
}
private PointChange calcChange(PointDouble point, StickLine oldLine, StickLine newLine) {
return Stickables.calcPointDiffBasedOnStickLineChange(0, point, new StickLineChange(oldLine, newLine));
}
private static PointDouble point(double x, double y) {
return new PointDouble(x, y);
}
private static StickLine line(double xStart, double yStart, double xEnd, double yEnd) {
return new StickLine(point(xStart, yStart), point(xEnd, yEnd));
}
private static StickLine hLine(double xStart, double xEnd, double y) {
return line(xStart, y, xEnd, y);
}
private static StickLine vLine(double x, double yStart, double yEnd) {
return line(x, yStart, x, yEnd);
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/test/com/baselet/control/ 0000755 0001750 0001750 00000000000 12533641120 023133 5 ustar ben ben umlet-2015-06-03_UMLet_v13.3/BaseletElements/test/com/baselet/control/SharedUtilsTest.java 0000644 0001750 0001750 00000001323 12533641120 027064 0 ustar ben ben package com.baselet.control;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class SharedUtilsTest {
@Test
public void testRealignToGridRoundToNearest() {
assertEquals(10, SharedUtils.realignToGridRoundToNearest(false, 5.0));
assertEquals(10, SharedUtils.realignToGridRoundToNearest(false, 9.0));
assertEquals(0, SharedUtils.realignToGridRoundToNearest(false, 4.0));
assertEquals(-10, SharedUtils.realignToGridRoundToNearest(false, -5.0));
assertEquals(-10, SharedUtils.realignToGridRoundToNearest(false, -9.0));
assertEquals(0, SharedUtils.realignToGridRoundToNearest(false, -3.0));
assertEquals(0, SharedUtils.realignToGridRoundToNearest(false, 0));
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/.project 0000644 0001750 0001750 00000000607 12533641120 017751 0 ustar ben ben
BaseletElements
org.eclipse.jdt.core.javabuilder
org.eclipse.jdt.core.javanature
umlet-2015-06-03_UMLet_v13.3/BaseletElements/.classpath 0000644 0001750 0001750 00000000634 12533641120 020265 0 ustar ben ben
umlet-2015-06-03_UMLet_v13.3/BaseletElements/.gitignore 0000644 0001750 0001750 00000000006 12533641120 020263 0 ustar ben ben /bin/
umlet-2015-06-03_UMLet_v13.3/BaseletElements/.settings/ 0000755 0001750 0001750 00000000000 12533641120 020215 5 ustar ben ben umlet-2015-06-03_UMLet_v13.3/BaseletElements/.settings/org.eclipse.jdt.core.prefs 0000644 0001750 0001750 00000057557 12533641120 025222 0 ustar ben ben eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=18
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
org.eclipse.jdt.core.formatter.blank_lines_before_field=0
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=true
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
org.eclipse.jdt.core.formatter.comment.format_header=true
org.eclipse.jdt.core.formatter.comment.format_html=true
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=false
org.eclipse.jdt.core.formatter.comment.format_line_comments=true
org.eclipse.jdt.core.formatter.comment.format_source_code=true
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
org.eclipse.jdt.core.formatter.comment.line_length=9999
org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=false
org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
org.eclipse.jdt.core.formatter.compact_else_if=true
org.eclipse.jdt.core.formatter.continuation_indentation=2
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_empty_lines=false
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
org.eclipse.jdt.core.formatter.indentation.size=4
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.join_lines_in_comments=true
org.eclipse.jdt.core.formatter.join_wrapped_lines=false
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
org.eclipse.jdt.core.formatter.lineSplit=999
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false
org.eclipse.jdt.core.formatter.tabulation.char=tab
org.eclipse.jdt.core.formatter.tabulation.size=4
org.eclipse.jdt.core.formatter.use_on_off_tags=true
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=false
org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
umlet-2015-06-03_UMLet_v13.3/BaseletElements/.settings/org.eclipse.jdt.ui.prefs 0000644 0001750 0001750 00000012172 12533641120 024667 0 ustar ben ben cleanup.add_default_serial_version_id=false
cleanup.add_generated_serial_version_id=true
cleanup.add_missing_annotations=true
cleanup.add_missing_deprecated_annotations=true
cleanup.add_missing_methods=false
cleanup.add_missing_nls_tags=false
cleanup.add_missing_override_annotations=true
cleanup.add_missing_override_annotations_interface_methods=true
cleanup.add_serial_version_id=false
cleanup.always_use_blocks=true
cleanup.always_use_parentheses_in_expressions=false
cleanup.always_use_this_for_non_static_field_access=false
cleanup.always_use_this_for_non_static_method_access=false
cleanup.convert_to_enhanced_for_loop=true
cleanup.correct_indentation=false
cleanup.format_source_code=true
cleanup.format_source_code_changes_only=false
cleanup.make_local_variable_final=true
cleanup.make_parameters_final=false
cleanup.make_private_fields_final=false
cleanup.make_type_abstract_if_missing_method=false
cleanup.make_variable_declarations_final=false
cleanup.never_use_blocks=false
cleanup.never_use_parentheses_in_expressions=true
cleanup.organize_imports=true
cleanup.qualify_static_field_accesses_with_declaring_class=false
cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
cleanup.qualify_static_member_accesses_with_declaring_class=true
cleanup.qualify_static_method_accesses_with_declaring_class=false
cleanup.remove_private_constructors=true
cleanup.remove_trailing_whitespaces=true
cleanup.remove_trailing_whitespaces_all=true
cleanup.remove_trailing_whitespaces_ignore_empty=false
cleanup.remove_unnecessary_casts=true
cleanup.remove_unnecessary_nls_tags=true
cleanup.remove_unused_imports=false
cleanup.remove_unused_local_variables=false
cleanup.remove_unused_private_fields=true
cleanup.remove_unused_private_members=false
cleanup.remove_unused_private_methods=true
cleanup.remove_unused_private_types=true
cleanup.sort_members=false
cleanup.sort_members_all=false
cleanup.use_blocks=true
cleanup.use_blocks_only_for_return_and_throw=false
cleanup.use_parentheses_in_expressions=true
cleanup.use_this_for_non_static_field_access=true
cleanup.use_this_for_non_static_field_access_only_if_necessary=true
cleanup.use_this_for_non_static_method_access=true
cleanup.use_this_for_non_static_method_access_only_if_necessary=true
cleanup_profile=_Umlet Cleanup
cleanup_settings_version=2
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=_Umlet Formatter
formatter_settings_version=12
sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false
sp_cleanup.add_missing_annotations=true
sp_cleanup.add_missing_deprecated_annotations=true
sp_cleanup.add_missing_methods=false
sp_cleanup.add_missing_nls_tags=false
sp_cleanup.add_missing_override_annotations=true
sp_cleanup.add_missing_override_annotations_interface_methods=true
sp_cleanup.add_serial_version_id=false
sp_cleanup.always_use_blocks=true
sp_cleanup.always_use_parentheses_in_expressions=false
sp_cleanup.always_use_this_for_non_static_field_access=false
sp_cleanup.always_use_this_for_non_static_method_access=false
sp_cleanup.convert_to_enhanced_for_loop=true
sp_cleanup.correct_indentation=false
sp_cleanup.format_source_code=true
sp_cleanup.format_source_code_changes_only=false
sp_cleanup.make_local_variable_final=false
sp_cleanup.make_parameters_final=false
sp_cleanup.make_private_fields_final=true
sp_cleanup.make_type_abstract_if_missing_method=false
sp_cleanup.make_variable_declarations_final=true
sp_cleanup.never_use_blocks=false
sp_cleanup.never_use_parentheses_in_expressions=true
sp_cleanup.on_save_use_additional_actions=true
sp_cleanup.organize_imports=true
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
sp_cleanup.remove_private_constructors=true
sp_cleanup.remove_trailing_whitespaces=true
sp_cleanup.remove_trailing_whitespaces_all=true
sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
sp_cleanup.remove_unnecessary_casts=true
sp_cleanup.remove_unnecessary_nls_tags=true
sp_cleanup.remove_unused_imports=false
sp_cleanup.remove_unused_local_variables=false
sp_cleanup.remove_unused_private_fields=true
sp_cleanup.remove_unused_private_members=false
sp_cleanup.remove_unused_private_methods=true
sp_cleanup.remove_unused_private_types=true
sp_cleanup.sort_members=false
sp_cleanup.sort_members_all=false
sp_cleanup.use_blocks=true
sp_cleanup.use_blocks_only_for_return_and_throw=false
sp_cleanup.use_parentheses_in_expressions=true
sp_cleanup.use_this_for_non_static_field_access=true
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
sp_cleanup.use_this_for_non_static_method_access=true
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
umlet-2015-06-03_UMLet_v13.3/BaseletElements/.settings/org.eclipse.core.resources.prefs 0000644 0001750 0001750 00000000071 12533641120 026426 0 ustar ben ben eclipse.preferences.version=1
encoding/=UTF-8
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/ 0000755 0001750 0001750 00000000000 12533641120 017066 5 ustar ben ben umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/ 0000755 0001750 0001750 00000000000 12533641120 017644 5 ustar ben ben umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/ 0000755 0001750 0001750 00000000000 12533641120 021263 5 ustar ben ben umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/ 0000755 0001750 0001750 00000000000 12533641120 022714 5 ustar ben ben umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/ 0000755 0001750 0001750 00000000000 12533641120 023776 5 ustar ben ben umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/FirstRunFacet.java 0000644 0001750 0001750 00000000244 12533641120 027360 0 ustar ben ben package com.baselet.element.facet;
public abstract class FirstRunFacet extends Facet {
@Override
public boolean handleOnFirstRun() {
return true;
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/Buffer.java 0000644 0001750 0001750 00000002364 12533641120 026057 0 ustar ben ben package com.baselet.element.facet;
/**
* represents the space buffer around the printed PropertiesText
* Many Facets set restrictions via the buffer (e.g. a Package element should never print text over the upper left rectangle)
* The most important buffer-reader is the TextPrintFacet which uses it to calculate the text position
*/
public class Buffer {
private double top = 0; // the top space where no text should be placed (e.g. the upper left rectangle of the Package element)
private double left = 0;
private double right = 0;
public double getTop() {
return top;
}
public double getLeft() {
return left;
}
public double getRight() {
return right;
}
public void addToLeft(double inc) {
left += inc;
}
public void addToRight(double inc) {
right += inc;
}
/**
* sets the required top buffer. it is always the max from this or the previous buffer, because the facets are independent from each other
* if one required 20px and the other 10px, in general 20px are required to satisfy the requirements of both facets
*/
public void setTopMin(double newMin) {
top = Math.max(top, newMin);
}
public void addToLeftAndRight(double inc) {
addToLeft(inc);
addToRight(inc);
}
}
././@LongLink 0000644 0000000 0000000 00000000146 00000000000 011604 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/FirstRunKeyValueFacet.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/FirstRunKeyValueFacet.jav0000644 0001750 0001750 00000000264 12533641120 030667 0 ustar ben ben package com.baselet.element.facet;
public abstract class FirstRunKeyValueFacet extends KeyValueFacet {
@Override
public boolean handleOnFirstRun() {
return true;
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/specific/ 0000755 0001750 0001750 00000000000 12533641120 025563 5 ustar ben ben ././@LongLink 0000644 0000000 0000000 00000000150 00000000000 011577 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/specific/StateTypeFacet.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/specific/StateTypeFacet.j0000644 0001750 0001750 00000005130 12533641120 030622 0 ustar ben ben package com.baselet.element.facet.specific;
import java.util.Arrays;
import java.util.List;
import com.baselet.control.basics.geom.Dimension;
import com.baselet.control.basics.geom.PointDouble;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.element.facet.FirstRunKeyValueFacet;
import com.baselet.element.facet.PropertiesParserState;
/**
* must be in first-run because it manipulates the left buffer which is used by second-run facets
* must handle values in parsingFinished when drawer-setup is finished
*/
public class StateTypeFacet extends FirstRunKeyValueFacet {
public static final StateTypeFacet INSTANCE = new StateTypeFacet();
private StateTypeFacet() {}
private enum ActionTypeEnum {
STATE, SENDER, RECEIVER
}
@Override
public KeyValue getKeyValue() {
return new KeyValue("type",
new ValueInfo(ActionTypeEnum.STATE, "a default state"),
new ValueInfo(ActionTypeEnum.SENDER, "an action which sends a signal"),
new ValueInfo(ActionTypeEnum.RECEIVER, "an action which receives a signal"));
}
@Override
public void handleValue(final String value, final PropertiesParserState state) {
// only act if parsing is finished to make sure DrawHandler-Setup is finished
}
private void drawActionState(final DrawHandler drawer, Dimension s) {
int radius = Math.min(20, Math.min(s.width, s.height) / 5);
drawer.drawRectangleRound(0, 0, s.width, s.height, radius);
}
private double depth(Dimension s) {
return s.width / 5.0;
}
private PointDouble p(double x, double y) {
return new PointDouble(x, y);
}
@Override
public void parsingFinished(PropertiesParserState state, List handledLines) {
if (handledLines.isEmpty()) {
drawActionState(state.getDrawer(), state.getGridElementSize());
}
else if (handledLines.size() == 1) {
final PropertiesParserState state1 = state;
DrawHandler drawer = state1.getDrawer();
ActionTypeEnum type = ActionTypeEnum.valueOf(extractValue(handledLines.get(0).toUpperCase()));
Dimension s = state1.getGridElementSize();
if (type == ActionTypeEnum.STATE) {
drawActionState(drawer, s);
}
else if (type == ActionTypeEnum.SENDER) {
drawer.drawLines(Arrays.asList(p(0, 0), p(s.width - depth(s), 0), p(s.width, s.height / 2.0), p(s.width - depth(s), s.height), p(0, s.height), p(0, 0)));
}
else if (type == ActionTypeEnum.RECEIVER) {
state1.getBuffer().addToLeft(depth(s));
drawer.drawLines(Arrays.asList(p(0, 0), p(s.width, 0), p(s.width, s.height), p(0, s.height), p(depth(s), s.height / 2.0), p(0, 0)));
}
}
}
}
././@LongLink 0000644 0000000 0000000 00000000151 00000000000 011600 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/specific/InnerClassFacet.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/specific/InnerClassFacet.0000644 0001750 0001750 00000006317 12533641120 030577 0 ustar ben ben package com.baselet.element.facet.specific;
import java.util.Arrays;
import java.util.List;
import java.util.Stack;
import com.baselet.control.basics.XValues;
import com.baselet.control.enums.AlignHorizontal;
import com.baselet.control.enums.AlignVertical;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.diagram.draw.helper.ColorOwn;
import com.baselet.element.facet.Alignment;
import com.baselet.element.facet.Facet;
import com.baselet.element.facet.PropertiesParserState;
import com.baselet.gui.AutocompletionText;
public class InnerClassFacet extends Facet {
public static final InnerClassFacet INSTANCE = new InnerClassFacet();
private InnerClassFacet() {}
private static final int BUFFER_PIXEL_PER_INNER = 5;
private static final int H_SPACE = 4;
private static final String START = "{innerclass";
private static final String END = "innerclass}";
@Override
public boolean checkStart(String line, PropertiesParserState state) {
return line.equals(START) || line.equals(END);
}
@Override
public void handleLine(String line, PropertiesParserState state) {
Stack innerClassStartPoints = getOrInit(state);
DrawHandler drawer = state.getDrawer();
if (line.equals(START)) {
ClassSettings settings = new ClassSettings(state.getAlignment().getHorizontal(), state.getAlignment().getVertical(), getDividerPos(drawer, state));
innerClassStartPoints.add(settings);
state.getBuffer().addToLeftAndRight(BUFFER_PIXEL_PER_INNER);
state.increaseTextPrintPosition(H_SPACE);
state.getAlignment().reset();
}
else if (line.equals(END)) {
ClassSettings previousClassSettings = innerClassStartPoints.pop();
double start = previousClassSettings.start;
double height = getDividerPos(drawer, state) - start;
XValues xLimit = state.getXLimits(height);
ColorOwn oldColor = drawer.getBackgroundColor();
drawer.setBackgroundColor(ColorOwn.TRANSPARENT);
drawer.drawRectangle(xLimit.getLeft(), start, xLimit.getSpace(), height);
drawer.setBackgroundColor(oldColor);
state.increaseTextPrintPosition(H_SPACE);
state.getBuffer().addToLeftAndRight(-BUFFER_PIXEL_PER_INNER);
Alignment alignment = state.getAlignment();
alignment.setHorizontal(false, previousClassSettings.hAlign);
alignment.setVertical(false, previousClassSettings.vAlign);
}
}
private double getDividerPos(DrawHandler drawer, PropertiesParserState state) {
return state.getTextPrintPosition() - drawer.textHeightMax();
}
private Stack getOrInit(PropertiesParserState state) {
return state.getOrInitFacetResponse(InnerClassFacet.class, new Stack());
}
private static class ClassSettings {
private final AlignHorizontal hAlign;
private final AlignVertical vAlign;
private final double start;
public ClassSettings(AlignHorizontal hAlign, AlignVertical vAlign, double startpoint) {
super();
this.hAlign = hAlign;
this.vAlign = vAlign;
start = startpoint;
}
}
@Override
public List getAutocompletionStrings() {
return Arrays.asList(new AutocompletionText(START, "begin inner class"), new AutocompletionText(END, "end inner class"));
}
}
././@LongLink 0000644 0000000 0000000 00000000157 00000000000 011606 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/specific/UpperRightSymbolFacet.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/specific/UpperRightSymbol0000644 0001750 0001750 00000007757 12533641120 031005 0 ustar ben ben package com.baselet.element.facet.specific;
import java.util.Arrays;
import java.util.List;
import com.baselet.control.basics.geom.PointDouble;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.diagram.draw.helper.ColorOwn;
import com.baselet.element.facet.FirstRunKeyValueFacet;
import com.baselet.element.facet.PropertiesParserState;
/**
* must be in first-run because it manipulates the left buffer which is used by second-run facets
* must handle values in parsingFinished when drawer-setup is finished
*/
public class UpperRightSymbolFacet extends FirstRunKeyValueFacet {
public static final UpperRightSymbolFacet INSTANCE = new UpperRightSymbolFacet();
private UpperRightSymbolFacet() {}
private enum UpperRightSymbolEnum {
USECASE, ARTIFACT, COMPONENT
}
@Override
public KeyValue getKeyValue() {
return new KeyValue("symbol",
new ValueInfo(UpperRightSymbolEnum.USECASE, "draw a use case symbol"),
new ValueInfo(UpperRightSymbolEnum.ARTIFACT, "draw an artifact symbol"),
new ValueInfo(UpperRightSymbolEnum.COMPONENT, "draw a component symbol"));
}
private static final int DISTANCE = 5;
@Override
public void handleValue(String value, PropertiesParserState state) {
// only act if parsing is finished to make sure DrawHandler-Setup is finished
}
@Override
public void parsingFinished(PropertiesParserState state, List handledLines) {
if (!handledLines.isEmpty()) {
DrawHandler drawer = state.getDrawer();
ColorOwn prevBackgroundColor = drawer.getBackgroundColor();
drawer.setBackgroundColor(ColorOwn.TRANSPARENT);
UpperRightSymbolEnum symbol = UpperRightSymbolEnum.valueOf(extractValue(handledLines.get(0)).toUpperCase());
double eW = state.getGridElementSize().getWidth();
double fs = drawer.getFontSize();
if (symbol == UpperRightSymbolEnum.USECASE) {
double cW = fs * 2.5;
double cH = fs;
drawer.drawEllipse(eW - cW - DISTANCE, DISTANCE, cW, cH);
state.getBuffer().setTopMin(DISTANCE);
}
else if (symbol == UpperRightSymbolEnum.ARTIFACT) {
double cW = fs * 1.5;
double cH = fs * 1.8;
double corner = fs * 0.5;
List p = Arrays.asList(
new PointDouble(eW - cW - DISTANCE, DISTANCE),
new PointDouble(eW - DISTANCE - corner, DISTANCE),
new PointDouble(eW - DISTANCE, DISTANCE + corner),
new PointDouble(eW - DISTANCE, DISTANCE + cH),
new PointDouble(eW - cW - DISTANCE, DISTANCE + cH)
);
PointDouble px = new PointDouble(eW - DISTANCE - corner, DISTANCE + corner);
drawer.drawLines(p.get(0), p.get(1), p.get(2), p.get(3), p.get(4), p.get(0));
drawer.drawLines(p.get(1), px, p.get(2));
state.getBuffer().setTopMin(DISTANCE + fs * 0.3);
}
else if (symbol == UpperRightSymbolEnum.COMPONENT) {
double partHeight = fs * 0.4;
double nonPartHeight = fs * 0.3;
double partWidth = partHeight * 2;
double cH = partHeight * 2 + nonPartHeight * 3;
double cW = cH * 0.8;
drawer.drawRectangle(eW - cW - partWidth / 2 - DISTANCE, DISTANCE + nonPartHeight, partWidth, partHeight); // upper small rect
drawer.drawRectangle(eW - cW - partWidth / 2 - DISTANCE, DISTANCE + partHeight + nonPartHeight * 2, partWidth, partHeight); // lower small rect
drawer.drawLine(eW - cW - DISTANCE, DISTANCE + partHeight + nonPartHeight, eW - cW - DISTANCE, DISTANCE + partHeight + nonPartHeight * 2); // connection between 2 rects
drawer.drawLines(Arrays.asList( // draw large rectangle around
new PointDouble(eW - cW - DISTANCE, DISTANCE + nonPartHeight),
new PointDouble(eW - cW - DISTANCE, DISTANCE),
new PointDouble(eW - DISTANCE, DISTANCE),
new PointDouble(eW - DISTANCE, DISTANCE + cH),
new PointDouble(eW - cW - DISTANCE, DISTANCE + cH),
new PointDouble(eW - cW - DISTANCE, DISTANCE + cH - nonPartHeight)
));
state.getBuffer().setTopMin(DISTANCE + fs * 0.3);
}
drawer.setBackgroundColor(prevBackgroundColor);
}
}
}
././@LongLink 0000644 0000000 0000000 00000000150 00000000000 011577 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/specific/HierarchyFacet.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/specific/HierarchyFacet.j0000644 0001750 0001750 00000016545 12533641120 030632 0 ustar ben ben package com.baselet.element.facet.specific;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.baselet.control.basics.geom.PointDouble;
import com.baselet.control.constants.SharedConstants;
import com.baselet.control.enums.AlignHorizontal;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.diagram.draw.DrawHandler.Layer;
import com.baselet.diagram.draw.helper.ColorOwn;
import com.baselet.element.draw.DrawHelper;
import com.baselet.element.facet.Facet;
import com.baselet.element.facet.KeyValueFacet;
import com.baselet.element.facet.PropertiesParserState;
import com.baselet.gui.AutocompletionText;
public class HierarchyFacet extends Facet {
private static final double ARROW_LENGTH = 12;
private static final double CIRCLE_DIAMETER = 10;
private static final String KEY = "type";
private static final class ReferencePoint {
PointDouble p;
boolean hasSymbol = false;
public ReferencePoint(PointDouble p) {
super();
this.p = p;
}
}
private static final class Cache {
HierarchyType type = HierarchyType.Actor;
private int lineNr;
private final List points = new ArrayList();
}
public static enum HierarchyType {
Actor, Package, WorkProcess;
}
public static final HierarchyFacet INSTANCE = new HierarchyFacet();
@Override
public boolean checkStart(String line, PropertiesParserState state) {
return true;
}
@Override
public void handleLine(String line, PropertiesParserState state) {
if (line.isEmpty()) {
return;
}
Cache cache = state.getOrInitFacetResponse(HierarchyFacet.class, new Cache());
for (HierarchyType type : HierarchyType.values()) {
if (line.equals(KEY + KeyValueFacet.SEP + type)) {
cache.type = type;
return;
}
}
DrawHandler drawer = state.getDrawer();
drawer.setLayer(Layer.Foreground);
ColorOwn bgBefore = drawer.getBackgroundColor();
drawer.setBackgroundColor(ColorOwn.TRANSPARENT);
String lineWithoutTabs = line.replace("\t", "");
int tabCount = line.length() - lineWithoutTabs.length();
int border = 10;
PointDouble upperLeftPoint = null;
PointDouble lowerRightPoint = null;
PointDouble textPos = null;
if (cache.type == HierarchyType.Actor) {
int actorDimension = 10;
int actorHCenter = border + actorDimension + actorDimension * 5 * tabCount;
int actorVTop = border + cache.lineNr * actorDimension * 6;
DrawHelper.drawActor(drawer, actorHCenter, actorVTop, actorDimension);
upperLeftPoint = new PointDouble(actorHCenter, actorVTop + actorDimension * 5.5 + ARROW_LENGTH);
lowerRightPoint = new PointDouble(actorHCenter - actorDimension * 2, actorVTop + actorDimension * 2.5);
drawLinesAndUpperLeftSymbol(lowerRightPoint, drawer, cache, lineWithoutTabs, tabCount, true);
textPos = new PointDouble(actorHCenter + actorDimension * 2, actorVTop + actorDimension * 3);
drawer.print(lineWithoutTabs, textPos, AlignHorizontal.LEFT);
updateElementSize(state, lineWithoutTabs, lowerRightPoint, textPos, drawer.textWidth(lineWithoutTabs), DrawHelper.headToLegLength(actorDimension));
}
else if (cache.type == HierarchyType.Package) {
int fullHeight = 20;
int fullWidth = 30;
double xPos = border + tabCount * fullWidth * 1.4;
double yPos = border + cache.lineNr * fullHeight * 1.6;
DrawHelper.drawPackage(drawer, xPos, yPos, 5, 10, fullHeight, fullWidth);
upperLeftPoint = new PointDouble(xPos + fullWidth * 0.3, yPos + fullHeight + CIRCLE_DIAMETER);
lowerRightPoint = new PointDouble(xPos, yPos + fullHeight * 0.5);
drawLinesAndUpperLeftSymbol(lowerRightPoint, drawer, cache, lineWithoutTabs, tabCount, false);
textPos = new PointDouble(xPos + fullWidth * 1.15, yPos + fullHeight * 0.8);
drawer.print(lineWithoutTabs, textPos, AlignHorizontal.LEFT);
updateElementSize(state, lineWithoutTabs, lowerRightPoint, textPos, drawer.textWidth(lineWithoutTabs), fullHeight + SharedConstants.DEFAULT_GRID_SIZE);
}
else if (cache.type == HierarchyType.WorkProcess) {
int fullHeight = 40;
int fullWidth = 140;
double xPos = border + tabCount * fullWidth;
double yPos = border + cache.lineNr * fullHeight * 1.2;
drawer.drawEllipse(xPos, yPos, fullWidth, fullHeight);
upperLeftPoint = new PointDouble(xPos + fullWidth * 0.5, yPos + fullHeight + ARROW_LENGTH);
lowerRightPoint = new PointDouble(xPos, yPos + fullHeight * 0.5);
drawLinesAndUpperLeftSymbol(lowerRightPoint, drawer, cache, lineWithoutTabs, tabCount, true);
textPos = new PointDouble(xPos + fullWidth / 2.0, yPos + fullHeight / 2.0 + drawer.textHeight(lineWithoutTabs) / 2.0);
drawer.print(lineWithoutTabs, textPos, AlignHorizontal.CENTER);
updateElementSize(state, lineWithoutTabs, lowerRightPoint, textPos, fullWidth / 2, fullHeight);
}
// store last point as reference
if (tabCount == 0) {
cache.points.clear();
}
// for each tab which is missing in this line compared to the previous one, remove one stored point
while (cache.points.size() > tabCount) {
cache.points.remove(cache.points.size() - 1);
}
cache.points.add(new ReferencePoint(upperLeftPoint));
cache.lineNr++;
drawer.setLayer(Layer.Background);
drawer.setBackgroundColor(bgBefore);
}
private void updateElementSize(PropertiesParserState state, String lineWithoutTabs, PointDouble lowerRightPoint, PointDouble textPos, double widthAddon, double heightAddon) {
state.updateMinimumSize(textPos.x + widthAddon, lowerRightPoint.y + heightAddon);
}
private static void drawLinesAndUpperLeftSymbol(PointDouble lowerRightPoint, DrawHandler drawer, Cache cache, String lineWithoutTabs, int tabCount, boolean arrow) {
if (tabCount != 0) {
try {
ReferencePoint ref = cache.points.get(tabCount - 1);
PointDouble p1 = new PointDouble(lowerRightPoint.x, lowerRightPoint.y);
PointDouble p2 = new PointDouble(ref.p.x, lowerRightPoint.y);
PointDouble p3 = new PointDouble(ref.p.x, ref.p.y);
drawer.drawLines(p1, p2, p3);
if (!ref.hasSymbol) {
ref.hasSymbol = true;
if (arrow) {
PointDouble upper = new PointDouble(ref.p.x, ref.p.y - ARROW_LENGTH);
PointDouble lowerLeft = new PointDouble(ref.p.x - ARROW_LENGTH / 2, ref.p.y);
PointDouble lowerRight = new PointDouble(ref.p.x + ARROW_LENGTH / 2, ref.p.y);
drawer.drawLines(upper, lowerLeft, lowerRight, upper);
}
else {
int dist = 2;
double circleRadius = CIRCLE_DIAMETER / 2;
drawer.drawCircle(ref.p.x, ref.p.y - circleRadius, circleRadius);
drawer.drawLine(ref.p.x, ref.p.y - CIRCLE_DIAMETER + dist, ref.p.x, ref.p.y - dist);
drawer.drawLine(ref.p.x - circleRadius + dist, ref.p.y - circleRadius, ref.p.x + circleRadius - dist, ref.p.y - circleRadius);
}
}
} catch (IndexOutOfBoundsException e) {
throw new RuntimeException("Too many tabs in line nr." + (cache.lineNr + 1) + ": " + lineWithoutTabs);
}
}
}
@Override
public List getAutocompletionStrings() {
return Arrays.asList(new AutocompletionText(KEY + KeyValueFacet.SEP + HierarchyType.Actor, "draws hierarchy of actors"),
new AutocompletionText(KEY + KeyValueFacet.SEP + HierarchyType.Package, "draws hierarchy of packages"),
new AutocompletionText(KEY + KeyValueFacet.SEP + HierarchyType.WorkProcess, "draws hierarchy of work processes"));
}
}
././@LongLink 0000644 0000000 0000000 00000000157 00000000000 011606 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/specific/SpecialStateTypeFacet.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/specific/SpecialStateType0000644 0001750 0001750 00000011222 12533641120 030727 0 ustar ben ben package com.baselet.element.facet.specific;
import java.util.List;
import com.baselet.control.basics.XValues;
import com.baselet.control.basics.geom.Dimension;
import com.baselet.control.basics.geom.PointDouble;
import com.baselet.control.enums.AlignHorizontal;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.diagram.draw.helper.ColorOwn;
import com.baselet.diagram.draw.helper.ColorOwn.Transparency;
import com.baselet.element.facet.KeyValueFacet;
import com.baselet.element.facet.PropertiesParserState;
public class SpecialStateTypeFacet extends KeyValueFacet {
public static final SpecialStateTypeFacet INSTANCE = new SpecialStateTypeFacet();
private SpecialStateTypeFacet() {}
private enum StateTypeEnum {
INITIAL, FINAL, FLOW_FINAL, TERMINATION, DECISION, HISTORY_SHALLOW, HISTORY_DEEP
}
@Override
public KeyValue getKeyValue() {
return new KeyValue("type",
new ValueInfo(StateTypeEnum.INITIAL, "an initial state"),
new ValueInfo(StateTypeEnum.FINAL, "a final state for the activity"),
new ValueInfo(StateTypeEnum.FLOW_FINAL, "a final state for a flow"),
new ValueInfo(StateTypeEnum.HISTORY_SHALLOW, "a shallow history state"),
new ValueInfo(StateTypeEnum.HISTORY_DEEP, "a deep history state"),
new ValueInfo(StateTypeEnum.TERMINATION, "a termination state"),
new ValueInfo(StateTypeEnum.DECISION, "a decision"));
}
@Override
public void handleValue(final String value, final PropertiesParserState state) {
DrawHandler drawer = state.getDrawer();
StateTypeEnum type = StateTypeEnum.valueOf(value.toUpperCase());
Dimension s = state.getGridElementSize();
// IMPORTANT NOTE: Make sure the element looks good in Swing and GWT because it's quite complex because of 1px displacements (check in UML State Machine palette)
double w = getWidth(s);
double h = getHeight(s);
if (type == StateTypeEnum.INITIAL) {
drawBlackEllipse(drawer, w - 1, h - 1, 1);
}
else if (type == StateTypeEnum.FINAL) {
drawer.drawEllipse(0, 0, w, h);
ColorOwn oldFg = drawer.getForegroundColor();
drawer.setForegroundColor(ColorOwn.TRANSPARENT); // don't use foregroundcolor for the inner circle, because otherwise in Swing it would look very ugly
double ellipseDistance = Math.max(w - 1, h - 1) / 5.5;
drawBlackEllipse(drawer, w - ellipseDistance * 2, h - ellipseDistance * 2, ellipseDistance);
drawer.setForegroundColor(oldFg);
}
else if (type == StateTypeEnum.FLOW_FINAL) {
drawer.drawEllipse(0, 0, w, h);
double upperY = h / 6;
double lowerY = h - upperY;
XValues upperXVal = XValues.createForEllipse(upperY, h, w);
XValues lowerXVal = XValues.createForEllipse(lowerY, h, w);
drawer.drawLine(upperXVal.getLeft(), upperY, lowerXVal.getRight(), lowerY);
drawer.drawLine(lowerXVal.getLeft(), lowerY, upperXVal.getRight(), upperY);
}
else if (type == StateTypeEnum.HISTORY_SHALLOW || type == StateTypeEnum.HISTORY_DEEP) {
String text;
if (type == StateTypeEnum.HISTORY_SHALLOW) {
text = "*H*";
}
else {
text = "*H**";
}
drawer.drawEllipse(0, 0, w, h);
double x = (w - drawer.textWidth(text)) / 2;
double y = (h + drawer.textHeight(text)) / 2;
drawer.print(text, new PointDouble(x, y), AlignHorizontal.LEFT);
}
else if (type == StateTypeEnum.TERMINATION) {
drawer.drawLine(0, 0, w, h);
drawer.drawLine(w, 0, 0, h);
}
else if (type == StateTypeEnum.DECISION) {
drawDecision(drawer, w, h);
}
}
private void drawDecision(final DrawHandler drawer, final double w, final double h) {
drawer.drawLines(new PointDouble(0.5 + w / 2, 1), new PointDouble(w, 0.5 + h / 2), new PointDouble(0.5 + w / 2, h), new PointDouble(1, 0.5 + h / 2), new PointDouble(0.5 + w / 2, 1));
}
private void drawBlackEllipse(final DrawHandler drawer, double width, double height, double xY) {
ColorOwn oldBg = drawer.getBackgroundColor();
if (drawer.getBackgroundColor() == ColorOwn.DEFAULT_BACKGROUND) {
drawer.setBackgroundColor(ColorOwn.BLACK.transparency(Transparency.FOREGROUND));
}
else {
drawer.setBackgroundColor(drawer.getBackgroundColor().transparency(Transparency.FOREGROUND));
}
drawer.drawEllipse(xY, xY, width, height);
drawer.setBackgroundColor(oldBg);
}
@Override
public void parsingFinished(PropertiesParserState state, List handledLines) {
if (handledLines.isEmpty()) { // default is decision
Dimension s = state.getGridElementSize();
drawDecision(state.getDrawer(), getWidth(s), getHeight(s));
}
}
private int getHeight(Dimension s) {
return s.getHeight() - 1;
}
private int getWidth(Dimension s) {
return s.getWidth() - 1;
}
}
././@LongLink 0000644 0000000 0000000 00000000154 00000000000 011603 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/specific/TemplateClassFacet.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/specific/TemplateClassFac0000644 0001750 0001750 00000010413 12533641120 030660 0 ustar ben ben package com.baselet.element.facet.specific;
import java.util.Arrays;
import java.util.List;
import com.baselet.control.SharedUtils;
import com.baselet.control.basics.geom.PointDouble;
import com.baselet.control.basics.geom.Rectangle;
import com.baselet.control.enums.AlignHorizontal;
import com.baselet.control.enums.LineType;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.diagram.draw.helper.ColorOwn;
import com.baselet.diagram.draw.helper.Style;
import com.baselet.diagram.draw.helper.StyleException;
import com.baselet.element.facet.FirstRunKeyValueFacet;
import com.baselet.element.facet.PropertiesParserState;
import com.baselet.element.sticking.polygon.PointDoubleStickingPolygonGenerator;
import com.baselet.element.sticking.polygon.SimpleStickingPolygonGenerator;
/**
* must be in first run, because the execution of Class.drawCommonContent() depends on the result of this facet
*/
public class TemplateClassFacet extends FirstRunKeyValueFacet {
public static final TemplateClassFacet INSTANCE = new TemplateClassFacet();
private TemplateClassFacet() {}
public static final int UPPER_SPACE = 3;
public static final int LOWER_SPACE = 3;
public static final int LEFT_SPACE = 12;
@Override
public KeyValue getKeyValue() {
return new KeyValue("template", new ValueInfo("text", "print template rectangle on top right corner"));
}
@Override
public void handleValue(String value, PropertiesParserState state) {
// only act after parsing
}
private static int round(double val) {
return SharedUtils.realignToGrid(false, val, true);
}
@Override
public void parsingFinished(PropertiesParserState state, List handledLines) {
DrawHandler drawer = state.getDrawer();
int height = state.getGridElementSize().getHeight();
int width = state.getGridElementSize().getWidth();
if (handledLines.isEmpty()) {
drawer.drawRectangle(0, 0, width, height);
state.setStickingPolygonGenerator(SimpleStickingPolygonGenerator.INSTANCE);
}
else if (handledLines.size() == 1) {
List points = TemplateClassFacet.drawTemplateClass(extractValue(handledLines.get(0)), drawer, state, height, width);
state.setStickingPolygonGenerator(new PointDoubleStickingPolygonGenerator(points));
}
else {
throw new StyleException("Only one class template is allowed");
}
}
private static List drawTemplateClass(String templateClassText, DrawHandler drawer, PropertiesParserState state, int height, int width) {
Rectangle tR = calcTemplateRect(templateClassText, drawer, width);
int classTopEnd = round(tR.getHeight() / 2.0);
int classWidth = width - round(tR.getWidth() / 2.0);
PointDouble start = new PointDouble(0, classTopEnd);
List p = Arrays.asList(
start,
new PointDouble(tR.getX(), classTopEnd),
new PointDouble(tR.getX(), 0),
new PointDouble(width, 0),
new PointDouble(width, tR.getHeight()),
new PointDouble(classWidth, tR.getHeight()),
new PointDouble(classWidth, height),
new PointDouble(0, height),
start);
// SET BUFFERS FOR REDUCED CLASS BORDER
state.getBuffer().setTopMin(tR.getHeight());
state.getBuffer().addToRight(width - classWidth);
// DRAW BACKGROUND RECT
Style style = drawer.getStyleClone();
drawer.setForegroundColor(ColorOwn.TRANSPARENT);
drawer.drawLines(p);
drawer.setStyle(style); // reset style to state before manipulations
// DRAW RIGHT RECT
drawer.setLineType(LineType.DASHED);
drawer.setBackgroundColor(ColorOwn.TRANSPARENT);
drawer.drawRectangle(tR);
drawer.setStyle(style); // reset style to state before manipulations
// DRAW PARTIAL CLASS BORDER
drawer.drawLines(p.get(1), p.get(0), p.get(7), p.get(6), p.get(5));
// DRAW TEMPLATE TEXT
drawer.print(templateClassText, width - drawer.getDistanceBorderToText(), tR.getHeight() - LOWER_SPACE, AlignHorizontal.RIGHT);
return p;
}
private static Rectangle calcTemplateRect(String templateClassText, DrawHandler drawer, int width) {
double templateHeight = drawer.textHeightMax() + UPPER_SPACE + LOWER_SPACE;
double templateWidth = drawer.textWidth(templateClassText) + LEFT_SPACE;
Rectangle tR = new Rectangle(width - templateWidth, 0.0, templateWidth, templateHeight);
return tR;
}
}
././@LongLink 0000644 0000000 0000000 00000000155 00000000000 011604 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/specific/SubStateSymbolFacet.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/specific/SubStateSymbolFa0000644 0001750 0001750 00000003610 12533641120 030675 0 ustar ben ben package com.baselet.element.facet.specific;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.diagram.draw.DrawHandler.Layer;
import com.baselet.diagram.draw.helper.ColorOwn;
import com.baselet.element.facet.KeyValueFacet;
import com.baselet.element.facet.PropertiesParserState;
public class SubStateSymbolFacet extends KeyValueFacet {
public static final SubStateSymbolFacet INSTANCE = new SubStateSymbolFacet();
private SubStateSymbolFacet() {}
private enum SubStateSymbolEnum {
SUBSTATE
}
@Override
public KeyValue getKeyValue() {
return new KeyValue("symbol",
new ValueInfo(SubStateSymbolEnum.SUBSTATE, "draw a substate symbol in the lower right corner"));
}
private static final int DIST_RIGHT = 15;
private static final int DIST_BOTTOM = 5;
@Override
public void handleValue(String value, PropertiesParserState state) {
DrawHandler drawer = state.getDrawer();
drawer.setLayer(Layer.Foreground); // should be always on top of background
ColorOwn prevBackgroundColor = drawer.getBackgroundColor();
drawer.setBackgroundColor(ColorOwn.TRANSPARENT);
SubStateSymbolEnum symbol = SubStateSymbolEnum.valueOf(value.toUpperCase());
final double w = state.getGridElementSize().getWidth();
final double h = state.getGridElementSize().getHeight();
if (symbol == SubStateSymbolEnum.SUBSTATE) {
double cW = drawer.getFontSize() * 1.6;
double cH = cW * 0.4;
double cR = cW * 0.15;
double connectorW = cH;
drawer.drawRectangleRound(w - DIST_RIGHT - cW, h - DIST_BOTTOM - cH, cW, cH, cR);
drawer.drawRectangleRound(w - DIST_RIGHT - cW - cW - connectorW, h - DIST_BOTTOM - cH, cW, cH, cR);
drawer.drawLine(w - DIST_RIGHT - cW - connectorW, h - DIST_BOTTOM - cH / 2, w - DIST_RIGHT - cW, h - DIST_BOTTOM - cH / 2);
drawer.setLayer(Layer.Background);
drawer.setBackgroundColor(prevBackgroundColor);
}
}
}
././@LongLink 0000644 0000000 0000000 00000000152 00000000000 011601 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/specific/ActiveClassFacet.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/specific/ActiveClassFacet0000644 0001750 0001750 00000003626 12533641120 030661 0 ustar ben ben package com.baselet.element.facet.specific;
import java.util.List;
import com.baselet.control.basics.XValues;
import com.baselet.control.enums.Priority;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.element.facet.FirstRunKeyValueFacet;
import com.baselet.element.facet.PropertiesParserState;
/**
* must be in first-run because it manipulates the left buffer which is used by second-run facets
* must handle values in parsingFinished when drawer-setup is finished
*/
public class ActiveClassFacet extends FirstRunKeyValueFacet {
public static final ActiveClassFacet INSTANCE = new ActiveClassFacet();
private ActiveClassFacet() {}
private static enum ClassTypeEnum {
ACTCLASS
}
@Override
public KeyValue getKeyValue() {
return new KeyValue("type", new ValueInfo(ClassTypeEnum.ACTCLASS, "make class active (double left/right border)"));
}
private static final int SPACING = 6;
@Override
public void handleValue(String value, PropertiesParserState state) {
// only act if parsing is finished to make sure DrawHandler-Setup is finished
}
@Override
public void parsingFinished(PropertiesParserState state, List handledLines) {
if (!handledLines.isEmpty()) {
ClassTypeEnum.valueOf(extractValue(handledLines.get(0)).toUpperCase()); // parse the value to make sure only valid types are accepted
state.getBuffer().addToLeftAndRight(SPACING);
XValues xLimits = state.getXLimits(state.getTextPrintPosition());
DrawHandler drawer = state.getDrawer();
drawer.drawLine(xLimits.getLeft(), state.getBuffer().getTop(), xLimits.getLeft(), state.getGridElementSize().getHeight());
drawer.drawLine(xLimits.getRight(), state.getBuffer().getTop(), xLimits.getRight(), state.getGridElementSize().getHeight());
}
}
@Override
public Priority getPriority() {
return Priority.LOW; // must be after template class to work
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/Settings.java 0000644 0001750 0001750 00000012722 12533641120 026445 0 ustar ben ben package com.baselet.element.facet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import com.baselet.control.basics.XValues;
import com.baselet.control.enums.AlignHorizontal;
import com.baselet.control.enums.AlignVertical;
import com.baselet.control.enums.ElementStyle;
import com.baselet.element.facet.common.BackgroundColorFacet;
import com.baselet.element.facet.common.ElementStyleFacet;
import com.baselet.element.facet.common.FontSizeFacet;
import com.baselet.element.facet.common.ForegroundColorFacet;
import com.baselet.element.facet.common.GroupFacet;
import com.baselet.element.facet.common.HorizontalAlignFacet;
import com.baselet.element.facet.common.LayerFacet;
import com.baselet.element.facet.common.LineTypeFacet;
import com.baselet.element.facet.common.LineWidthFacet;
import com.baselet.element.facet.common.SeparatorLineFacet;
import com.baselet.element.facet.common.TextPrintFacet;
import com.baselet.element.facet.common.TransparencyFacet;
import com.baselet.element.facet.common.VerticalAlignFacet;
import com.baselet.element.facet.specific.HierarchyFacet;
import com.baselet.element.relation.facet.LineDescriptionFacet;
import com.baselet.element.relation.facet.LineDescriptionPositionFacet;
import com.baselet.element.relation.facet.RelationLineTypeFacet;
/**
* The basic settings of any NewGridElement.
* They represent the default values for many important Facets (valign, halign, style) and defines the facets which should be applied to this element
* It also specifies if the default text printing should be enabled for this element (e.g. Relation has its own text printing logic)
*/
public abstract class Settings {
// the following lists are default facet configurations. they are declared here as a simple overview and for easy reuse
private static final List BASE = listOf(BackgroundColorFacet.INSTANCE, TransparencyFacet.INSTANCE, ForegroundColorFacet.INSTANCE, LayerFacet.INSTANCE, LineWidthFacet.INSTANCE, GroupFacet.INSTANCE);
private static final List BASE_WITH_LINETYPE = listOf(BASE, LineTypeFacet.INSTANCE);
private static final List BASE_EXTENDED = listOf(BASE_WITH_LINETYPE, TextPrintFacet.INSTANCE, FontSizeFacet.INSTANCE);
protected static final List RELATION = listOf(BASE, FontSizeFacet.INSTANCE, RelationLineTypeFacet.INSTANCE, LineDescriptionFacet.INSTANCE, LineDescriptionPositionFacet.INSTANCE_MESSAGE_START, LineDescriptionPositionFacet.INSTANCE_MESSAGE_END, LineDescriptionPositionFacet.INSTANCE_ROLE_START, LineDescriptionPositionFacet.INSTANCE_ROLE_END);
protected static final List MANUALRESIZE = listOf(BASE_EXTENDED, VerticalAlignFacet.INSTANCE, HorizontalAlignFacet.INSTANCE, ElementStyleFacet.INSTANCE);
protected static final List NOTEXT = BASE_WITH_LINETYPE;
protected static final List AUTORESIZE = listOf(BASE_EXTENDED, SeparatorLineFacet.INSTANCE);
protected static final List HIERARCHY = listOf(BASE_WITH_LINETYPE, FontSizeFacet.INSTANCE, ElementStyleFacet.INSTANCE_AUTORESIZEONLY, HierarchyFacet.INSTANCE);
protected static List listOf(Facet... f) {
List facetList = new ArrayList();
facetList.addAll(Arrays.asList(f));
return facetList;
}
protected static List listOf(List list, Facet... f) {
List facetList = new ArrayList(list);
facetList.addAll(Arrays.asList(f));
return facetList;
}
/**
* calculates the left and right x value for a certain y value
*/
public XValues getXValues(double y, int height, int width) {
return new XValues(0, width); // default is rectangle form
}
public AlignVertical getVAlign() {
return AlignVertical.TOP;
}
public AlignHorizontal getHAlign() {
return AlignHorizontal.CENTER;
}
public abstract ElementStyle getElementStyle();
/**
* facets are checked and applied during text parsing.
* e.g. if a line matches "--" and the facet SeparatorLine is setup for the current element,
* a separator line will be drawn instead of printing the text.
*
* First-run facets are parsed before any other ones, because they influence the whole diagram, even if they are located at the bottom
* e.g. style=wordwrap may be located at the bottom but has an influence on every printed line
*/
protected abstract List createFacets();
private List firstRunFacets;
private List secondRunFacets;
private void initFacets() {
if (firstRunFacets == null) {
firstRunFacets = new ArrayList();
secondRunFacets = new ArrayList();
addAll(createFacets());
sortListByPriority(firstRunFacets);
sortListByPriority(secondRunFacets);
}
}
private void addAll(List facets) {
for (Facet f : facets) {
if (f.handleOnFirstRun()) {
secondRunFacets.add(f);
}
else {
firstRunFacets.add(f);
}
}
}
/**
* makes sure that higher priorities are first in the list and therefore are handled first
*/
private void sortListByPriority(List extends Facet> facets) {
Collections.sort(facets, new Comparator() {
@Override
public int compare(Facet o1, Facet o2) {
return o1.getPriority().compareTo(o2.getPriority());
}
});
}
public final List getFacetsForSecondRun() {
initFacets();
return firstRunFacets;
}
public final List getFacetsForFirstRun() {
initFacets();
return secondRunFacets;
}
} umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/ 0000755 0001750 0001750 00000000000 12533641120 025266 5 ustar ben ben ././@LongLink 0000644 0000000 0000000 00000000146 00000000000 011604 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/LineWidthFacet.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/LineWidthFacet.jav0000644 0001750 0001750 00000001301 12533641120 030615 0 ustar ben ben package com.baselet.element.facet.common;
import com.baselet.control.constants.FacetConstants;
import com.baselet.element.facet.FirstRunKeyValueFacet;
import com.baselet.element.facet.PropertiesParserState;
public class LineWidthFacet extends FirstRunKeyValueFacet {
public static final LineWidthFacet INSTANCE = new LineWidthFacet();
private LineWidthFacet() {}
@Override
public KeyValue getKeyValue() {
return new KeyValue("lw", false, FacetConstants.LINE_WIDTH_DEFAULT + "", "linewidth as decimal number (1.5, 2, ...)");
}
@Override
public void handleValue(String value, PropertiesParserState state) {
state.getDrawer().setLineWidth(Float.valueOf(value));
}
}
././@LongLink 0000644 0000000 0000000 00000000151 00000000000 011600 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/ElementStyleFacet.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/ElementStyleFacet.0000644 0001750 0001750 00000002360 12533641120 030645 0 ustar ben ben package com.baselet.element.facet.common;
import com.baselet.control.enums.ElementStyle;
import com.baselet.element.facet.FirstRunKeyValueFacet;
import com.baselet.element.facet.PropertiesParserState;
public class ElementStyleFacet extends FirstRunKeyValueFacet {
private static final ValueInfo NORESIZE_VALUE = new ValueInfo(ElementStyle.NORESIZE, "disable manual resizing");
private static final ValueInfo WORDWRAP_VALUE = new ValueInfo(ElementStyle.WORDWRAP, "wrap lines at the end of the line");
private static final ValueInfo AUTORESIZE_VALUE = new ValueInfo(ElementStyle.AUTORESIZE, "resizes element as text grows");
public static final ElementStyleFacet INSTANCE = new ElementStyleFacet(AUTORESIZE_VALUE, WORDWRAP_VALUE, NORESIZE_VALUE);
public static final ElementStyleFacet INSTANCE_AUTORESIZEONLY = new ElementStyleFacet(AUTORESIZE_VALUE);
private final ValueInfo[] valueInfo;
private ElementStyleFacet(ValueInfo... valueInfo) {
this.valueInfo = valueInfo;
}
@Override
public KeyValue getKeyValue() {
return new KeyValue("style", valueInfo);
}
@Override
public void handleValue(String value, PropertiesParserState state) {
state.setElementStyle(ElementStyle.valueOf(value.toUpperCase()));
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/LineTypeFacet.java0000644 0001750 0001750 00000002217 12533641120 030627 0 ustar ben ben package com.baselet.element.facet.common;
import java.util.Arrays;
import java.util.List;
import com.baselet.control.enums.LineType;
import com.baselet.element.facet.FirstRunKeyValueFacet;
import com.baselet.element.facet.PropertiesParserState;
public class LineTypeFacet extends FirstRunKeyValueFacet {
public static final LineTypeFacet INSTANCE = new LineTypeFacet();
private LineTypeFacet() {}
@Override
public KeyValue getKeyValue() {
return new KeyValue("lt",
new ValueInfo(LineType.SOLID.getValue(), "solid lines"),
new ValueInfo(LineType.DASHED.getValue(), "dashed lines"),
new ValueInfo(LineType.DOTTED.getValue(), "dotted lines"));
}
private static final List supportedTypes = Arrays.asList(LineType.SOLID, LineType.DASHED, LineType.DOTTED);
@Override
public void handleValue(String value, PropertiesParserState state) {
LineType lt = null;
for (LineType s : supportedTypes) {
if (s.getValue().equals(value)) {
lt = s;
}
}
if (lt == null) {
throw new RuntimeException(); // will be translated to usage message
}
state.getDrawer().setLineType(lt);
}
}
././@LongLink 0000644 0000000 0000000 00000000146 00000000000 011604 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/TextPrintFacet.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/TextPrintFacet.jav0000644 0001750 0001750 00000015363 12533641120 030704 0 ustar ben ben package com.baselet.element.facet.common;
import java.util.Collections;
import java.util.List;
import com.baselet.control.basics.XValues;
import com.baselet.control.enums.AlignHorizontal;
import com.baselet.control.enums.AlignVertical;
import com.baselet.control.enums.ElementStyle;
import com.baselet.control.enums.Priority;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.diagram.draw.DrawHandler.Layer;
import com.baselet.diagram.draw.TextSplitter;
import com.baselet.element.facet.Facet;
import com.baselet.element.facet.PropertiesParserState;
import com.baselet.gui.AutocompletionText;
public class TextPrintFacet extends Facet {
public static final TextPrintFacet INSTANCE = new TextPrintFacet();
private TextPrintFacet() {}
@Override
public boolean checkStart(String line, PropertiesParserState state) {
return !line.startsWith("//"); // comments start with // and are not printed
}
@Override
public void handleLine(String line, PropertiesParserState state) {
DrawHandler drawer = state.getDrawer();
drawer.setLayer(Layer.Foreground); // should be always on top of background
setupAtFirstLine(line, drawer, state);
if (state.getElementStyle() == ElementStyle.WORDWRAP && !line.trim().isEmpty()) { // empty lines are skipped (otherwise they would get lost)
printLineWithWordWrap(line, drawer, state);
}
else {
printLine(line, drawer, state);
}
drawer.setLayer(Layer.Background);
}
private static void printLineWithWordWrap(String line, DrawHandler drawer, PropertiesParserState state) {
String wrappedLine;
while (state.getTextPrintPosition() < state.getGridElementSize().height && !line.trim().isEmpty()) {
double spaceForText = state.getXLimitsForArea(state.getTextPrintPosition(), drawer.textHeightMax(), false).getSpace() - drawer.getDistanceBorderToText() * 2;
wrappedLine = TextSplitter.splitString(line, spaceForText, drawer);
printLine(wrappedLine, drawer, state);
line = line.substring(wrappedLine.length()).trim();
}
}
private static void printLine(String line, DrawHandler drawer, PropertiesParserState state) {
XValues xLimitsForText = state.getXLimitsForArea(state.getTextPrintPosition(), drawer.textHeightMax(), false);
Double spaceNotUsedForText = state.getGridElementSize().width - xLimitsForText.getSpace();
if (!spaceNotUsedForText.equals(Double.NaN)) { // NaN is possible if xlimits calculation contains e.g. a division by zero
state.updateMinimumWidth(spaceNotUsedForText + drawer.textWidth(line));
}
AlignHorizontal hAlign = state.getAlignment().getHorizontal();
drawer.print(line, calcHorizontalTextBoundaries(xLimitsForText, drawer.getDistanceBorderToText(), hAlign), state.getTextPrintPosition(), hAlign);
state.increaseTextPrintPosition(drawer.textHeightMaxWithSpace());
}
/**
* before the first line is printed, some space-setup is necessary to make sure the text position is correct
*/
private static void setupAtFirstLine(String line, DrawHandler drawer, PropertiesParserState state) {
boolean isFirstPrintedLine = state.getFacetResponse(TextPrintFacet.class, true);
if (isFirstPrintedLine) {
state.getBuffer().setTopMin(calcStartPointFromVAlign(drawer, state));
state.getBuffer().setTopMin(calcTopDisplacementToFitLine(line, state, drawer));
state.setFacetResponse(TextPrintFacet.class, false);
}
}
private static double calcStartPointFromVAlign(DrawHandler drawer, PropertiesParserState state) {
double returnVal = drawer.textHeightMax(); // print method is located at the bottom of the text therefore add text height (important for UseCase etc where text must not reach out of the border)
if (state.getAlignment().getVertical() == AlignVertical.TOP) {
returnVal += drawer.getDistanceBorderToText() + state.getBuffer().getTop();
}
else if (state.getAlignment().getVertical() == AlignVertical.CENTER) {
returnVal += (state.getGridElementSize().height - state.getTotalTextBlockHeight()) / 2 + state.getBuffer().getTop() / 2;
}
else /* if (state.getvAlign() == AlignVertical.BOTTOM) */{
returnVal += state.getGridElementSize().height - state.getTotalTextBlockHeight() - drawer.textHeightMax() / 4; // 1/4 of textheight is a good value for large fontsizes and "deep" characters like "y"
}
return returnVal;
}
/**
* Calculates the necessary y-pos space to make the first line fit the xLimits of the element
* Currently only used by UseCase element to make sure the first line is moved down as long as it doesn't fit into the available space
*/
private static double calcTopDisplacementToFitLine(String firstLine, PropertiesParserState state, DrawHandler drawer) {
double displacement = state.getTextPrintPosition();
boolean wordwrap = state.getElementStyle() == ElementStyle.WORDWRAP;
if (!wordwrap) { // in case of wordwrap or no text, there is no top displacement
int BUFFER = 2; // a small buffer between text and outer border
double textHeight = drawer.textHeightMax();
double addedSpacePerIteration = textHeight / 2;
double availableWidthSpace = state.getXLimitsForArea(displacement, textHeight, true).getSpace() - BUFFER;
double accumulator = displacement;
int maxLoops = 1000;
while (accumulator < state.getGridElementSize().height && !TextSplitter.checkifStringFits(firstLine, availableWidthSpace, drawer)) {
if (maxLoops-- < 0) {
throw new RuntimeException("Endless loop during calculation of top displacement");
}
accumulator += addedSpacePerIteration;
double previousWidthSpace = availableWidthSpace;
availableWidthSpace = state.getXLimitsForArea(accumulator, textHeight, true).getSpace() - BUFFER;
// only set displacement if the last iteration resulted in a space gain (eg: for UseCase until the middle, for Class: stays on top because on a rectangle there is never a width-space gain)
if (availableWidthSpace > previousWidthSpace) {
displacement = accumulator;
}
}
}
return displacement;
}
private static double calcHorizontalTextBoundaries(XValues xLimitsForText, double distanceBorderToText, AlignHorizontal hAlign) {
double x;
if (hAlign == AlignHorizontal.LEFT) {
x = xLimitsForText.getLeft() + distanceBorderToText;
}
else if (hAlign == AlignHorizontal.CENTER) {
x = xLimitsForText.getSpace() / 2.0 + xLimitsForText.getLeft();
}
else /* if (state.gethAlign() == AlignHorizontal.RIGHT) */{
x = xLimitsForText.getRight() - distanceBorderToText;
}
return x;
}
@Override
public List getAutocompletionStrings() {
return Collections.emptyList(); // no autocompletion text for this facet
}
@Override
public Priority getPriority() {
return Priority.LOWEST; // only text not used by other facets should be printed
}
}
././@LongLink 0000644 0000000 0000000 00000000151 00000000000 011600 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/TransparencyFacet.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/TransparencyFacet.0000644 0001750 0001750 00000002276 12533641120 030712 0 ustar ben ben package com.baselet.element.facet.common;
import com.baselet.diagram.draw.helper.ColorOwn;
import com.baselet.diagram.draw.helper.StyleException;
import com.baselet.element.facet.FirstRunKeyValueFacet;
import com.baselet.element.facet.PropertiesParserState;
public class TransparencyFacet extends FirstRunKeyValueFacet {
public static final TransparencyFacet INSTANCE = new TransparencyFacet();
private TransparencyFacet() {}
@Override
public KeyValue getKeyValue() {
return new KeyValue("transparency", false, "0", "background color transparency in percent");
}
@Override
public void handleValue(String value, PropertiesParserState state) {
try {
int valInt = Integer.parseInt(value);
if (valInt < 0 || valInt > 100) {
throw new NumberFormatException();
}
double colorTransparencyValue = 255 - valInt * 2.55; // ColorOwn has 0 for full transparency and 255 for no transparency
ColorOwn bgColor = state.getDrawer().getBackgroundColor();
state.getDrawer().setBackgroundColor(bgColor.transparency((int) colorTransparencyValue));
} catch (NumberFormatException e) {
throw new StyleException("The value must be between 0 and 100");
}
}
} ././@LongLink 0000644 0000000 0000000 00000000152 00000000000 011601 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/VerticalAlignFacet.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/VerticalAlignFacet0000644 0001750 0001750 00000001536 12533641120 030705 0 ustar ben ben package com.baselet.element.facet.common;
import com.baselet.control.enums.AlignVertical;
import com.baselet.element.facet.FirstRunKeyValueFacet;
import com.baselet.element.facet.PropertiesParserState;
public class VerticalAlignFacet extends FirstRunKeyValueFacet {
public static final VerticalAlignFacet INSTANCE = new VerticalAlignFacet();
private VerticalAlignFacet() {}
@Override
public KeyValue getKeyValue() {
return new KeyValue("valign",
new ValueInfo(AlignVertical.TOP, "vertical text alignment"),
new ValueInfo(AlignVertical.CENTER, "vertical text alignment"),
new ValueInfo(AlignVertical.BOTTOM, "vertical text alignment"));
}
@Override
public void handleValue(String value, PropertiesParserState state) {
state.getAlignment().setVertical(true, AlignVertical.valueOf(value.toUpperCase()));
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/GroupFacet.java 0000644 0001750 0001750 00000001507 12533641120 030173 0 ustar ben ben package com.baselet.element.facet.common;
import com.baselet.diagram.draw.helper.StyleException;
import com.baselet.element.facet.FirstRunKeyValueFacet;
import com.baselet.element.facet.PropertiesParserState;
public class GroupFacet extends FirstRunKeyValueFacet {
public static final GroupFacet INSTANCE = new GroupFacet();
private GroupFacet() {}
public static final String KEY = "group";
@Override
public KeyValue getKeyValue() {
return new KeyValue(KEY, false, "1", "grouped elements are selected at once");
}
@Override
public void handleValue(String value, PropertiesParserState state) {
try {
state.setFacetResponse(GroupFacet.class, Integer.valueOf(value));
} catch (NumberFormatException e) {
throw new StyleException("value must be a positive or negative integer");
}
}
}
././@LongLink 0000644 0000000 0000000 00000000154 00000000000 011603 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/ForegroundColorFacet.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/ForegroundColorFac0000644 0001750 0001750 00000001372 12533641120 030737 0 ustar ben ben package com.baselet.element.facet.common;
import com.baselet.control.constants.FacetConstants;
import com.baselet.diagram.draw.helper.ColorOwn;
import com.baselet.element.facet.FirstRunKeyValueFacet;
import com.baselet.element.facet.PropertiesParserState;
public class ForegroundColorFacet extends FirstRunKeyValueFacet {
public static final ForegroundColorFacet INSTANCE = new ForegroundColorFacet();
private ForegroundColorFacet() {}
@Override
public KeyValue getKeyValue() {
return new KeyValue(FacetConstants.FOREGROUND_COLOR_KEY, false, "red", "foreground " + ColorOwn.EXAMPLE_TEXT);
}
@Override
public void handleValue(String value, PropertiesParserState state) {
state.getDrawer().setForegroundColor(value);
}
}
././@LongLink 0000644 0000000 0000000 00000000154 00000000000 011603 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/BackgroundColorFacet.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/BackgroundColorFac0000644 0001750 0001750 00000001372 12533641120 030704 0 ustar ben ben package com.baselet.element.facet.common;
import com.baselet.control.constants.FacetConstants;
import com.baselet.diagram.draw.helper.ColorOwn;
import com.baselet.element.facet.FirstRunKeyValueFacet;
import com.baselet.element.facet.PropertiesParserState;
public class BackgroundColorFacet extends FirstRunKeyValueFacet {
public static final BackgroundColorFacet INSTANCE = new BackgroundColorFacet();
private BackgroundColorFacet() {}
@Override
public KeyValue getKeyValue() {
return new KeyValue(FacetConstants.BACKGROUND_COLOR_KEY, false, "red", "background " + ColorOwn.EXAMPLE_TEXT);
}
@Override
public void handleValue(String value, PropertiesParserState state) {
state.getDrawer().setBackgroundColor(value);
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/FontSizeFacet.java0000644 0001750 0001750 00000001436 12533641120 030641 0 ustar ben ben package com.baselet.element.facet.common;
import com.baselet.diagram.draw.helper.StyleException;
import com.baselet.element.facet.FirstRunKeyValueFacet;
import com.baselet.element.facet.PropertiesParserState;
public class FontSizeFacet extends FirstRunKeyValueFacet {
public static final FontSizeFacet INSTANCE = new FontSizeFacet();
private FontSizeFacet() {}
@Override
public KeyValue getKeyValue() {
return new KeyValue("fontsize", false, "12", "font size as decimal number (12.5, 10.3,...)");
}
@Override
public void handleValue(String value, PropertiesParserState state) {
try {
state.getDrawer().setFontSize(Double.valueOf(value));
} catch (NumberFormatException e) {
throw new StyleException("value must be a decimal number");
}
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/LayerFacet.java 0000644 0001750 0001750 00000001746 12533641120 030160 0 ustar ben ben package com.baselet.element.facet.common;
import com.baselet.diagram.draw.helper.StyleException;
import com.baselet.element.facet.FirstRunKeyValueFacet;
import com.baselet.element.facet.PropertiesParserState;
public class LayerFacet extends FirstRunKeyValueFacet {
public static final LayerFacet INSTANCE = new LayerFacet();
private LayerFacet() {}
public static final String KEY = "layer";
public static final Integer DEFAULT_VALUE = 0;
public static final Integer DEFAULT_VALUE_RELATION = 1;
@Override
public KeyValue getKeyValue() {
return new KeyValue(KEY, false, DEFAULT_VALUE.toString(), "higher layers are shown on top of lowers. (-5, 0(=default), 3,...)");
}
@Override
public void handleValue(String value, PropertiesParserState state) {
try {
state.setFacetResponse(LayerFacet.class, Integer.valueOf(value));
} catch (NumberFormatException e) {
throw new StyleException("value must be a positive or negative integer");
}
}
}
././@LongLink 0000644 0000000 0000000 00000000152 00000000000 011601 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/SeparatorLineFacet.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/SeparatorLineFacet0000644 0001750 0001750 00000002623 12533641120 030727 0 ustar ben ben package com.baselet.element.facet.common;
import java.util.Arrays;
import java.util.List;
import com.baselet.control.basics.XValues;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.diagram.draw.DrawHandler.Layer;
import com.baselet.element.facet.Facet;
import com.baselet.element.facet.PropertiesParserState;
import com.baselet.gui.AutocompletionText;
public class SeparatorLineFacet extends Facet {
public static final SeparatorLineFacet INSTANCE = new SeparatorLineFacet();
protected SeparatorLineFacet() {}
public static final String KEY = "--";
private static final double Y_SPACE = 5;
@Override
public void handleLine(String line, PropertiesParserState state) {
DrawHandler drawer = state.getDrawer();
drawer.setLayer(Layer.Foreground); // should be always on top of background
double linePos = state.getTextPrintPosition() - drawer.textHeightMax() + Y_SPACE / 2;
XValues xPos = state.getXLimits(linePos);
drawer.drawLine(xPos.getLeft() + 0.5, linePos, xPos.getRight() - 1, linePos);
state.increaseTextPrintPosition(Y_SPACE);
drawer.setLayer(Layer.Background);
}
@Override
public boolean checkStart(String line, PropertiesParserState state) {
return line.equals(KEY);
}
@Override
public List getAutocompletionStrings() {
return Arrays.asList(new AutocompletionText(KEY, "draw horizontal line"));
}
}
././@LongLink 0000644 0000000 0000000 00000000172 00000000000 011603 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/SeparatorLineWithHalignChangeFacet.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/SeparatorLineWithH0000644 0001750 0001750 00000001117 12533641120 030725 0 ustar ben ben package com.baselet.element.facet.common;
import com.baselet.control.enums.AlignHorizontal;
import com.baselet.element.facet.PropertiesParserState;
public class SeparatorLineWithHalignChangeFacet extends SeparatorLineFacet {
public static final SeparatorLineWithHalignChangeFacet INSTANCE = new SeparatorLineWithHalignChangeFacet();
private SeparatorLineWithHalignChangeFacet() {}
@Override
public void handleLine(String line, PropertiesParserState state) {
state.getAlignment().setHorizontal(false, AlignHorizontal.LEFT);
super.handleLine(line, state);
}
}
././@LongLink 0000644 0000000 0000000 00000000176 00000000000 011607 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/TextBeforeFirstSeparatorCollectorFacet.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/TextBeforeFirstSep0000644 0001750 0001750 00000003706 12533641120 030746 0 ustar ben ben package com.baselet.element.facet.common;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.baselet.control.enums.Priority;
import com.baselet.element.facet.FirstRunFacet;
import com.baselet.element.facet.PropertiesParserState;
import com.baselet.gui.AutocompletionText;
/**
* the collector is the last first-run-facet which should be applied (therefore LOW prio)
* it must be in first-run to be applied before the drawCommonContent of the GridElement but after any other first-run-facet
*/
public class TextBeforeFirstSeparatorCollectorFacet extends FirstRunFacet {
public static final TextBeforeFirstSeparatorCollectorFacet INSTANCE = new TextBeforeFirstSeparatorCollectorFacet();
protected TextBeforeFirstSeparatorCollectorFacet() {}
public static class TextBeforeFirstSeparatorCollectorFacetResponse {
private boolean firstSepFound = false;
private final List lines = new ArrayList();
public List getLines() {
return lines;
}
}
@Override
public boolean checkStart(String line, PropertiesParserState state) {
return !getOrInit(state).firstSepFound;
}
@Override
public void handleLine(String line, PropertiesParserState state) {
if (line.equals(SeparatorLineFacet.KEY)) {
getOrInit(state).firstSepFound = true;
return;
}
else {
getOrInit(state).getLines().add(line);
}
}
@Override
public List getAutocompletionStrings() {
return Arrays.asList(new AutocompletionText(SeparatorLineFacet.KEY, "ends package title part"));
}
@Override
public Priority getPriority() {
return Priority.LOW; // only collect which is not used by any other facet
}
private TextBeforeFirstSeparatorCollectorFacetResponse getOrInit(PropertiesParserState state) {
return state.getOrInitFacetResponse(TextBeforeFirstSeparatorCollectorFacet.class, new TextBeforeFirstSeparatorCollectorFacetResponse());
}
}
././@LongLink 0000644 0000000 0000000 00000000154 00000000000 011603 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/HorizontalAlignFacet.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/common/HorizontalAlignFac0000644 0001750 0001750 00000001570 12533641120 030732 0 ustar ben ben package com.baselet.element.facet.common;
import com.baselet.control.enums.AlignHorizontal;
import com.baselet.element.facet.FirstRunKeyValueFacet;
import com.baselet.element.facet.PropertiesParserState;
public class HorizontalAlignFacet extends FirstRunKeyValueFacet {
public static final HorizontalAlignFacet INSTANCE = new HorizontalAlignFacet();
private HorizontalAlignFacet() {}
@Override
public KeyValue getKeyValue() {
return new KeyValue("halign",
new ValueInfo(AlignHorizontal.LEFT, "horizontal text alignment"),
new ValueInfo(AlignHorizontal.CENTER, "horizontal text alignment"),
new ValueInfo(AlignHorizontal.RIGHT, "horizontal text alignment"));
}
@Override
public void handleValue(String value, PropertiesParserState state) {
state.getAlignment().setHorizontal(true, AlignHorizontal.valueOf(value.toUpperCase()));
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/Facet.java 0000644 0001750 0001750 00000005346 12533641120 025673 0 ustar ben ben package com.baselet.element.facet;
import java.util.List;
import org.apache.log4j.Logger;
import com.baselet.control.enums.Priority;
import com.baselet.gui.AutocompletionText;
/**
* A Facet is a simple handler method which acts on certain lines and does a specific job if it should act.
* It is important that Facets are ALWAYS STATELESS.
* If any State is required, it should be stored using the {@link PropertiesParserState#getOrInitFacetResponse(Class, Object)} method
*/
public abstract class Facet {
protected Logger log = Logger.getLogger(Facet.class);
/**
* @param line the current line which is parsed
* @param state the current state of the parser
* @return true if the handleLine() method of this facet should be applied
*/
public abstract boolean checkStart(String line, PropertiesParserState state);
/**
* This method is invoked at the time when a specific line is parsed
* @param line the current line which is parsed
* @param state the current state of the parser
*/
public abstract void handleLine(String line, PropertiesParserState state);
/**
* @return a list of objects where each one represents one line for autocompletion
*/
public abstract List getAutocompletionStrings();
/**
* This method is called once for every Facet AFTER all lines of text has been parsed
* E.g. useful for facets which collect information with every line but need complete knowledge before they can do something with it
*
* @param state the current state of the parser
* @param handledLines the list of lines this facet has been applied to (in the order of the handleLine calls)
*/
public void parsingFinished(PropertiesParserState state, List handledLines) {
// default is no action
}
/**
* facets with higher priority will be applied before facets with lower priority:
* The order is: For all lines
* 1. Check all First-Run Facets from HIGHEST ... LOWEST
* 2. Check all Second-Run Facets from HIGHEST ... LOWEST
*/
public Priority getPriority() {
return Priority.DEFAULT;
}
/**
* The parser runs twice. Facets where this method returns true, are part of the first run, other facets are part of the second run
*
* Typically facets of the first run will influence the whole diagram, even if they are located at the bottom.
* e.g. bg=red must be known before drawing the common content of an element; style=autoresize must be known as soon as possible to make the size-calculations
*
* Facets of the second run have less side effects (e.g. printText just prints the current line, -- transforms to a horizontal line at the current print-position)
*/
public boolean handleOnFirstRun() {
return false;
}
}
././@LongLink 0000644 0000000 0000000 00000000146 00000000000 011604 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/PropertiesParserState.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/PropertiesParserState.jav0000644 0001750 0001750 00000011350 12533641120 031012 0 ustar ben ben package com.baselet.element.facet;
import java.util.HashMap;
import java.util.Map;
import com.baselet.control.basics.XValues;
import com.baselet.control.basics.geom.Dimension;
import com.baselet.control.enums.ElementStyle;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.element.sticking.polygon.SimpleStickingPolygonGenerator;
import com.baselet.element.sticking.polygon.StickingPolygonGenerator;
/**
* The PropertiesParserState contains the mutable state of the parser which changes constantly while parsing
* the properties printing related facets have explicit fields (for better usabilty), for any other Facet, the generic facetResponse map should be used for communication between facets and/or the gridelement
*
*/
public class PropertiesParserState {
private final Settings settings;
private final DrawHandler drawer;
private Alignment alignment;
private double textPrintPosition; // the current y position for drawing text, separator-lines and other properties-text-related stuff
private double minimumWidth;
private Buffer buffer;
private Dimension gridElementSize;
private ElementStyle elementStyle;
private StickingPolygonGenerator stickingPolygonGenerator = SimpleStickingPolygonGenerator.INSTANCE;
private double totalTextBlockHeight;
private final Map, Object> facetResponse = new HashMap, Object>();
public PropertiesParserState(Settings settings, DrawHandler drawer) {
this.settings = settings;
this.drawer = drawer;
}
public void resetValues(Dimension gridElementSize, double totalTextBlockHeight, boolean enableDrawing) {
alignment = new Alignment(settings);
textPrintPosition = 0;
minimumWidth = 0;
buffer = new Buffer();
this.gridElementSize = gridElementSize;
elementStyle = settings.getElementStyle();
stickingPolygonGenerator = SimpleStickingPolygonGenerator.INSTANCE;
this.totalTextBlockHeight = totalTextBlockHeight;
facetResponse.clear();
drawer.setEnableDrawing(enableDrawing);
}
public Alignment getAlignment() {
return alignment;
}
/**
* returns the current text print position including the top buffer
*/
public double getTextPrintPosition() {
return textPrintPosition + buffer.getTop();
}
/**
* use whenever the text print position should be increased (e.g. if -- draws a horizontal line, some vertical space should be added, or everytime TextPrintFacet prints a line)
*/
public void increaseTextPrintPosition(double inc) {
textPrintPosition += inc;
}
public Buffer getBuffer() {
return buffer;
}
public Dimension getGridElementSize() {
return gridElementSize;
}
public XValues getXLimits(double linePos) {
XValues xLimits = settings.getXValues(linePos, getGridElementSize().height, getGridElementSize().width);
xLimits.addLeft(buffer.getLeft());
xLimits.subRight(buffer.getRight());
return xLimits;
}
public XValues getXLimitsForArea(double bottomYPos, double areaHeight, boolean nanPriority) {
XValues xLimitsTop = getXLimits(bottomYPos - areaHeight);
XValues xLimitsBottom = getXLimits(bottomYPos);
XValues xLimits = xLimitsTop.intersect(xLimitsBottom, nanPriority);
return xLimits;
}
public void updateMinimumWidth(double width) {
minimumWidth = Math.max(minimumWidth, width);
}
public void updateMinimumSize(double width, double height) {
updateMinimumWidth(width);
getBuffer().setTopMin(height);
}
public double getCalculatedElementWidth() {
return minimumWidth;
}
public ElementStyle getElementStyle() {
return elementStyle;
}
public void setElementStyle(ElementStyle elementStyle) {
this.elementStyle = elementStyle;
}
public Settings getSettings() {
return settings;
}
public DrawHandler getDrawer() {
return drawer;
}
@SuppressWarnings("unchecked")
public T getFacetResponse(Class extends Facet> facetClass, T defaultValue) {
T mapValue = (T) facetResponse.get(facetClass);
if (mapValue == null) {
return defaultValue;
}
return mapValue;
}
public T getOrInitFacetResponse(Class extends Facet> facetClass, T defaultValue) {
T mapValue = getFacetResponse(facetClass, defaultValue);
setFacetResponse(facetClass, mapValue);
return mapValue;
}
public void setFacetResponse(Class extends Facet> facetClass, Object value) {
facetResponse.put(facetClass, value);
}
public StickingPolygonGenerator getStickingPolygonGenerator() {
return stickingPolygonGenerator;
}
public void setStickingPolygonGenerator(StickingPolygonGenerator stickingPolygonGenerator) {
this.stickingPolygonGenerator = stickingPolygonGenerator;
}
public double getTotalTextBlockHeight() {
return totalTextBlockHeight;
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/KeyValueFacet.java 0000644 0001750 0001750 00000006654 12533641120 027344 0 ustar ben ben package com.baselet.element.facet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.baselet.control.enums.FormatLabels;
import com.baselet.diagram.draw.helper.StyleException;
import com.baselet.gui.AutocompletionText;
public abstract class KeyValueFacet extends Facet {
public static class KeyValue {
private final String key;
private final boolean allValuesListed;
private final List valueInfos;
public KeyValue(String key, boolean allValuesListed, String value, String info) {
super();
this.key = key.toLowerCase();
this.allValuesListed = allValuesListed;
valueInfos = Arrays.asList(new ValueInfo(value, info));
}
public KeyValue(String key, ValueInfo... valueInfos) {
super();
this.key = key;
allValuesListed = true;
this.valueInfos = Arrays.asList(valueInfos);
}
public String getKey() {
return key;
}
public List getValueInfos() {
return valueInfos;
}
public String getValueString() {
StringBuilder sb = new StringBuilder();
if (allValuesListed) {
sb.append("Valid are: ");
for (ValueInfo vi : valueInfos) {
sb.append(vi.value.toString().toLowerCase()).append(',');
}
sb.deleteCharAt(sb.length() - 1);
}
else {
for (ValueInfo vi : valueInfos) {
sb.append(vi.info);
}
}
return sb.toString();
}
}
public static class ValueInfo {
private final Object value;
private final String info;
private final String base64Img;
public ValueInfo(Object value, String info) {
this(value, info, null);
}
public ValueInfo(Object value, String info, String base64Img) {
super();
this.value = value;
this.info = info;
this.base64Img = base64Img;
}
public Object getValue() {
return value;
}
private String getInfo() {
return info;
}
private String getBase64Img() {
return base64Img;
}
}
public static final String SEP = "=";
public abstract KeyValue getKeyValue();
public abstract void handleValue(String value, PropertiesParserState state);
@Override
public boolean checkStart(String line, PropertiesParserState state) {
return line.startsWith(getKeyWithSep());
}
@Override
public void handleLine(String line, PropertiesParserState state) {
String value = extractValue(line);
try {
handleValue(value, state);
} catch (Exception e) {
log.debug("KeyValue Error", e);
String errorMessage = getKeyValue().getValueString();
if (e instanceof StyleException) { // self defined exceptions overwrite the default message
errorMessage = e.getMessage();
}
throw new RuntimeException(FormatLabels.BOLD.getValue() + "Invalid value:" + FormatLabels.BOLD.getValue() + "\n" + getKeyWithSep() + value + "\n" + errorMessage);
}
}
protected String extractValue(String line) {
return line.substring(getKeyWithSep().length());
}
@Override
public List getAutocompletionStrings() {
List returnList = new ArrayList();
for (ValueInfo valueInfo : getKeyValue().getValueInfos()) {
returnList.add(new AutocompletionText(getKeyWithSep() + valueInfo.getValue().toString().toLowerCase(), valueInfo.getInfo(), valueInfo.getBase64Img()));
}
return returnList;
}
public String getKeyWithSep() {
return getKeyValue().getKey() + KeyValueFacet.SEP;
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/facet/Alignment.java 0000644 0001750 0001750 00000003071 12533641120 026560 0 ustar ben ben package com.baselet.element.facet;
import com.baselet.control.enums.AlignHorizontal;
import com.baselet.control.enums.AlignVertical;
public class Alignment {
private final AlignHorizontal horizontalDefault;
private final AlignVertical verticalDefault;
private AlignHorizontal horizontal;
private boolean horizontalGloballySet;
private AlignVertical vertical;
private boolean verticalGloballySet;
public Alignment(Settings settings) {
horizontalDefault = settings.getHAlign();
verticalDefault = settings.getVAlign();
horizontal = horizontalDefault;
vertical = verticalDefault;
horizontalGloballySet = false;
verticalGloballySet = false;
}
public AlignHorizontal getHorizontal() {
return horizontal;
}
public void setHorizontal(boolean setGlobal, AlignHorizontal horizontal) {
if (setGlobal) {
horizontalGloballySet = true;
this.horizontal = horizontal;
}
else if (!horizontalGloballySet) {
this.horizontal = horizontal;
}
}
public boolean isHorizontalGloballySet() {
return horizontalGloballySet;
}
public AlignVertical getVertical() {
return vertical;
}
public void setVertical(boolean setGlobal, AlignVertical vertical) {
if (setGlobal) {
verticalGloballySet = true;
this.vertical = vertical;
}
else if (!verticalGloballySet) {
this.vertical = vertical;
}
}
public boolean isVerticalGloballySet() {
return verticalGloballySet;
}
public void reset() {
setHorizontal(false, horizontalDefault);
setVertical(false, verticalDefault);
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/NewGridElement.java 0000644 0001750 0001750 00000044005 12533641120 026433 0 ustar ben ben package com.baselet.element;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
import org.apache.log4j.Logger;
import com.baselet.control.SharedUtils;
import com.baselet.control.basics.geom.Dimension;
import com.baselet.control.basics.geom.DimensionDouble;
import com.baselet.control.basics.geom.Line;
import com.baselet.control.basics.geom.Point;
import com.baselet.control.basics.geom.PointDouble;
import com.baselet.control.basics.geom.Rectangle;
import com.baselet.control.config.SharedConfig;
import com.baselet.control.constants.SharedConstants;
import com.baselet.control.enums.AlignHorizontal;
import com.baselet.control.enums.Direction;
import com.baselet.control.enums.ElementStyle;
import com.baselet.control.enums.LineType;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.diagram.draw.helper.ColorOwn;
import com.baselet.diagram.draw.helper.ColorOwn.Transparency;
import com.baselet.element.facet.Facet;
import com.baselet.element.facet.KeyValueFacet;
import com.baselet.element.facet.PropertiesParserState;
import com.baselet.element.facet.Settings;
import com.baselet.element.facet.common.GroupFacet;
import com.baselet.element.facet.common.LayerFacet;
import com.baselet.element.interfaces.Component;
import com.baselet.element.interfaces.DrawHandlerInterface;
import com.baselet.element.interfaces.GridElement;
import com.baselet.element.interfaces.GridElementDeprecatedAddons;
import com.baselet.element.sticking.PointChange;
import com.baselet.element.sticking.Stickable;
import com.baselet.element.sticking.StickableMap;
import com.baselet.element.sticking.Stickables;
import com.baselet.element.sticking.StickingPolygon;
import com.baselet.gui.AutocompletionText;
public abstract class NewGridElement implements GridElement {
private final Logger log = Logger.getLogger(NewGridElement.class);
private DrawHandler drawer; // this is the drawer for element specific stuff
private DrawHandler metaDrawer; // this is a separate drawer to draw stickingborder, selection-background etc.
private Component component;
private DrawHandlerInterface handler;
private List panelAttributes;
protected PropertiesParserState state;
protected final UndoHistory undoStack = new UndoHistory();
public void init(Rectangle bounds, String panelAttributes, String additionalAttributes, Component component, DrawHandlerInterface handler) {
this.component = component;
drawer = component.getDrawHandler();
metaDrawer = component.getMetaDrawHandler();
setPanelAttributesHelper(panelAttributes);
setRectangle(bounds);
this.handler = handler;
state = new PropertiesParserState(createSettings(), drawer);
setAdditionalAttributes(additionalAttributes);
}
@Override
public String getPanelAttributes() {
return SharedUtils.listToString("\n", panelAttributes);
}
@Override
public List getPanelAttributesAsList() {
return panelAttributes;
}
@Override
public void setPanelAttributes(String panelAttributes) {
setPanelAttributesHelper(panelAttributes);
updateModelFromText();
}
public void setPanelAttributesHelper(String panelAttributes) {
this.panelAttributes = Arrays.asList(panelAttributes.split("\n", -1)); // split with -1 to retain empty lines at the end
}
/**
* ugly workaround to avoid that the Resize().execute() call which calls setSize() on this model updates the model during the
* calculated model update from autoresize. Otherwise the drawer cache would get messed up (it gets cleaned up 2 times in a row and afterwards everything gets drawn 2 times).
* Best testcase is an autoresize element with a background. Write some text and everytime autresize triggers, the background is drawn twice.
*/
private boolean autoresizePossiblyInProgress = false;
@Override
public void updateModelFromText() {
autoresizePossiblyInProgress = true;
drawer.clearCache();
drawer.resetStyle(); // must be set before actions which depend on the fontsize (otherwise a changed fontsize would be recognized too late)
try {
PropertiesParser.parsePropertiesAndHandleFacets(this, state);
} catch (Exception e) {
log.info("Cannot parse Properties Text", e);
drawer.resetStyle();
String localizedMessage = e.getLocalizedMessage();
if (localizedMessage == null) {
localizedMessage = e.toString();
}
drawError(drawer, localizedMessage);
}
autoresizePossiblyInProgress = false;
component.afterModelUpdate();
}
protected void drawError(DrawHandler drawer, String errorText) {
drawer.setEnableDrawing(true);
drawer.setForegroundColor(ColorOwn.RED);
drawer.setBackgroundColor(ColorOwn.RED.transparency(Transparency.SELECTION_BACKGROUND));
drawer.setLineWidth(0.2);
drawer.drawRectangle(0, 0, getRealSize().width, getRealSize().height); // draw dotted rect (to enforce background color even if element has no border)
resetAndDrawMetaDrawerContent(metaDrawer);
drawer.print(errorText, 3, getRealSize().height * 0.5 - drawer.textHeightMax(), AlignHorizontal.LEFT);
}
void resetMetaDrawerAndDrawCommonContent(PropertiesParserState state, boolean resetMetaDrawer) {
drawCommonContent(state);
if (resetMetaDrawer) {
resetAndDrawMetaDrawerContent(metaDrawer);
}
}
protected abstract void drawCommonContent(PropertiesParserState state);
protected void resetAndDrawMetaDrawerContent(DrawHandler drawer) {
drawer.clearCache();
drawer.setForegroundColor(ColorOwn.TRANSPARENT);
drawer.setBackgroundColor(ColorOwn.SELECTION_BG);
drawer.drawRectangle(0, 0, getRealSize().width, getRealSize().height);
if (SharedConfig.getInstance().isDev_mode()) {
drawer.setForegroundColor(ColorOwn.BLACK);
drawer.setFontSize(10.5);
drawer.print(getId().toString(), new PointDouble(getRealSize().width - 3, getRealSize().height - 2), AlignHorizontal.RIGHT);
}
drawer.resetColorSettings();
if (SharedConfig.getInstance().isShow_stickingpolygon()) {
drawStickingPolygon(drawer);
}
}
@Override
public void setProperty(String key, Object newValue) {
StringBuilder sb = new StringBuilder("");
for (String line : getPanelAttributesAsList()) {
if (!line.startsWith(key)) {
sb.append(line).append("\n");
}
}
if (sb.length() > 0) { // remove last linebreak
sb.setLength(sb.length() - 1);
}
if (newValue != null) {
sb.append("\n").append(key).append(KeyValueFacet.SEP).append(newValue.toString()); // null will not be added as a value
}
setPanelAttributes(sb.toString());
}
@Override
public String getSetting(String key) {
for (String line : getPanelAttributesAsList()) {
if (line.startsWith(key + KeyValueFacet.SEP)) {
String[] split = line.split(KeyValueFacet.SEP, 2);
if (split.length > 1) {
return split[1];
}
}
}
return null;
}
@Override
public String getAdditionalAttributes() {
return ""; // usually GridElements have no additional attributes
}
@Override
public void setAdditionalAttributes(String additionalAttributes) {
// usually GridElements have no additional attributes
}
@Override
public boolean isInRange(Rectangle rect1) {
return rect1.contains(getRectangle());
}
@Override
public Set getResizeArea(int x, int y) {
Set returnSet = new HashSet();
if (state.getElementStyle() == ElementStyle.NORESIZE || state.getElementStyle() == ElementStyle.AUTORESIZE) {
return returnSet;
}
if (x <= 5 && x >= 0) {
returnSet.add(Direction.LEFT);
}
else if (x <= getRectangle().width && x >= getRectangle().width - 5) {
returnSet.add(Direction.RIGHT);
}
if (y <= 5 && y >= 0) {
returnSet.add(Direction.UP);
}
else if (y <= getRectangle().height && y >= getRectangle().height - 5) {
returnSet.add(Direction.DOWN);
}
return returnSet;
}
/**
* @deprecated use {@link #generateStickingBorder()} instead, because typically the stickingpolygon is created for the own Rectangle, and the other method guarantees that the correct zoom level is applied (important to make alternative StickingPolygonGenerators like PointDoubleStickingPolygonGenerator work)
*/
@Deprecated
@Override
public final StickingPolygon generateStickingBorder(Rectangle rect) {
return state.getStickingPolygonGenerator().generateStickingBorder(rect);
}
/**
* generates the StickingPolygon of the element using the rectangle as if the zoomlevel would be 100% (this is IMPORTANT because the sticking-calculation doesn't calculate the zoomlevel (see Issue 229 and 231)
* Should never be overwritten; if a specific StickingPolygon should be created, instead overwrite the StickingPolygonGenerator in PropertiesParserState eg: Class uses different Generators based on which facets are active (see Class.java)
*/
@Override
public final StickingPolygon generateStickingBorder() {
return generateStickingBorder(getRealRectangle()); // ALWAYS generate the stickingBorder as if zoom were 100%
}
private final void drawStickingPolygon(DrawHandler drawer) {
Rectangle rect = new Rectangle(0, 0, getRealSize().width, getRealSize().height);
StickingPolygon poly = this.generateStickingBorder(rect);
drawer.setLineType(LineType.DASHED);
drawer.setForegroundColor(ColorOwn.STICKING_POLYGON);
Vector extends Line> lines = poly.getStickLines();
drawer.drawLines(lines.toArray(new Line[lines.size()]));
drawer.setLineType(LineType.SOLID);
drawer.resetColorSettings();
}
@Override
public void setRectangle(Rectangle bounds) {
component.setBoundsRect(bounds);
}
@Override
public void setLocationDifference(int diffx, int diffy) {
setLocation(getRectangle().x + diffx, getRectangle().y + diffy);
}
@Override
public void setLocation(int x, int y) {
Rectangle rect = getRectangle();
rect.setLocation(x, y);
component.setBoundsRect(rect);
}
@Override
public void setSize(int width, int height) {
if (width != getRectangle().width || height != getRectangle().height) { // only change size if it is really different
Rectangle rect = getRectangle();
rect.setSize(width, height);
setRectangle(rect);
if (!autoresizePossiblyInProgress) {
updateModelFromText();
}
}
}
@Override
public Rectangle getRectangle() {
return component.getBoundsRect();
}
@Override
public void repaint() {
component.repaintComponent();
}
/**
* @see com.baselet.element.interfaces.GridElement#getRealSize()
*/
@Override
public Dimension getRealSize() {
return new Dimension(zoom(getRectangle().width), zoom(getRectangle().height));
}
public Rectangle getRealRectangle() {
return new Rectangle(zoom(getRectangle().x), zoom(getRectangle().y), zoom(getRectangle().width), zoom(getRectangle().height));
}
private int zoom(int val) {
return val * SharedConstants.DEFAULT_GRID_SIZE / getGridSize();
}
@Override
public Component getComponent() {
return component;
}
protected abstract Settings createSettings();
@Override
public List getAutocompletionList() {
List returnList = new ArrayList();
addAutocompletionTexts(returnList, state.getSettings().getFacetsForFirstRun());
addAutocompletionTexts(returnList, state.getSettings().getFacetsForSecondRun());
return returnList;
}
private void addAutocompletionTexts(List returnList, List extends Facet> facets) {
for (Facet f : facets) {
for (AutocompletionText t : f.getAutocompletionStrings()) {
returnList.add(t);
}
}
}
@Override
public Integer getLayer() {
return state.getFacetResponse(LayerFacet.class, LayerFacet.DEFAULT_VALUE);
}
@Override
public Integer getGroup() {
return state.getFacetResponse(GroupFacet.class, null);
}
public void handleAutoresize(DimensionDouble necessaryElementDimension, AlignHorizontal alignHorizontal) {
double hSpaceLeftAndRight = drawer.getDistanceBorderToText() * 2;
double width = necessaryElementDimension.getWidth() + hSpaceLeftAndRight;
double height = necessaryElementDimension.getHeight() + drawer.textHeightMax() / 2;
Dimension realSize = getRealSize();
double diffw = width - realSize.width;
double diffh = height - realSize.height;
int diffwInt = SharedUtils.realignTo(false, unzoom(diffw), true, getGridSize());
int diffhInt = SharedUtils.realignTo(false, unzoom(diffh), true, getGridSize());
List directions = null;
if (alignHorizontal == AlignHorizontal.LEFT) {
directions = Arrays.asList(Direction.RIGHT, Direction.DOWN);
}
else if (alignHorizontal == AlignHorizontal.RIGHT) {
diffwInt = -diffwInt;
directions = Arrays.asList(Direction.LEFT, Direction.DOWN);
}
else if (alignHorizontal == AlignHorizontal.CENTER) {
diffwInt = SharedUtils.realignTo(false, diffwInt / 2.0, true, getGridSize()) * 2;
directions = Arrays.asList(Direction.RIGHT, Direction.LEFT, Direction.DOWN);
}
drag(directions, diffwInt, diffhInt, new Point(0, 0), false, true, handler.getStickableMap(), false);
}
private double unzoom(double diffw) {
return diffw / SharedConstants.DEFAULT_GRID_SIZE * getGridSize();
}
@Override
public void setRectangleDifference(int diffx, int diffy, int diffw, int diffh, boolean firstDrag, StickableMap stickables, boolean undoable) {
Rectangle oldRect = getRectangle();
StickingPolygon stickingPolygonBeforeLocationChange = generateStickingBorder();
String oldAddAttr = getAdditionalAttributes();
setRectangle(new Rectangle(oldRect.x + diffx, oldRect.y + diffy, oldRect.getWidth() + diffw, oldRect.getHeight() + diffh));
moveStickables(stickables, undoable, oldRect, stickingPolygonBeforeLocationChange, oldAddAttr);
}
@Override
public void drag(Collection resizeDirection, int diffX, int diffY, Point mousePosBeforeDrag, boolean isShiftKeyDown, boolean firstDrag, StickableMap stickables, boolean undoable) {
Rectangle oldRect = getRectangle();
StickingPolygon stickingPolygonBeforeLocationChange = generateStickingBorder();
String oldAddAttr = getAdditionalAttributes();
if (resizeDirection.isEmpty()) { // Move GridElement
setLocationDifference(diffX, diffY);
}
else { // Resize GridElement
Rectangle rect = getRectangle();
if (isShiftKeyDown && diagonalResize(resizeDirection)) { // Proportional Resize
boolean mouseToRight = diffX > 0 && diffX > diffY;
boolean mouseDown = diffY > 0 && diffY > diffX;
boolean mouseLeft = diffX < 0 && diffX < diffY;
boolean mouseUp = diffY < 0 && diffY < diffX;
if (mouseToRight || mouseLeft) {
diffY = diffX;
}
if (mouseDown || mouseUp) {
diffX = diffY;
}
}
if (resizeDirection.contains(Direction.LEFT) && resizeDirection.contains(Direction.RIGHT)) {
rect.setX(rect.getX() - diffX / 2);
rect.setWidth(Math.max(rect.getWidth() + diffX, minSize()));
}
else if (resizeDirection.contains(Direction.LEFT)) {
int newWidth = rect.getWidth() - diffX;
if (newWidth >= minSize()) {
rect.setX(rect.getX() + diffX);
rect.setWidth(newWidth);
}
}
else if (resizeDirection.contains(Direction.RIGHT)) {
rect.setWidth(Math.max(rect.getWidth() + diffX, minSize()));
}
if (resizeDirection.contains(Direction.UP)) {
int newHeight = rect.getHeight() - diffY;
if (newHeight >= minSize()) {
rect.setY(rect.getY() + diffY);
rect.setHeight(newHeight);
}
}
if (resizeDirection.contains(Direction.DOWN)) {
rect.setHeight(Math.max(rect.getHeight() + diffY, minSize()));
}
setRectangle(rect);
if (!autoresizePossiblyInProgress) {
updateModelFromText();
}
}
moveStickables(stickables, undoable, oldRect, stickingPolygonBeforeLocationChange, oldAddAttr);
}
private void moveStickables(StickableMap stickables, boolean undoable, Rectangle oldRect, StickingPolygon stickingPolygonBeforeLocationChange, String oldAddAttr) {
Map> stickableChanges = Stickables.moveStickPointsBasedOnPolygonChanges(stickingPolygonBeforeLocationChange, generateStickingBorder(), stickables, getGridSize());
if (undoable) {
undoStack.add(new UndoInformation(getRectangle(), oldRect, stickableChanges, getGridSize(), oldAddAttr, getAdditionalAttributes()));
}
}
@Override
public void dragEnd() {
// only used by some specific elements like Relations
}
@Override
public boolean isSelectableOn(Point point) {
return getRectangle().contains(point);
}
private boolean diagonalResize(Collection resizeDirection) {
return resizeDirection.contains(Direction.UP) && resizeDirection.contains(Direction.RIGHT) ||
resizeDirection.contains(Direction.UP) && resizeDirection.contains(Direction.LEFT) ||
resizeDirection.contains(Direction.DOWN) && resizeDirection.contains(Direction.LEFT) ||
resizeDirection.contains(Direction.DOWN) && resizeDirection.contains(Direction.RIGHT);
}
protected DrawHandlerInterface getHandler() {
return handler;
}
public int getGridSize() {
return getHandler().getGridSize();
}
private int minSize() {
return handler.getGridSize() * 2;
}
@Override
public void undoDrag() {
execUndoInformation(true);
}
private void execUndoInformation(boolean undo) {
UndoInformation undoInfo = undoStack.get(undo);
if (undoInfo != null) {
setRectangle(getRectangle().add(undoInfo.getDiffRectangle(getGridSize(), undo)));
Stickables.applyChanges(undoInfo.getStickableMoves(undo), null);
setAdditionalAttributes(undoInfo.getAdditionalAttributes(undo));
}
}
@Override
public void redoDrag() {
execUndoInformation(false);
}
@Override
public void mergeUndoDrag() {
UndoInformation undoInfoA = undoStack.remove();
UndoInformation undoInfoB = undoStack.remove();
undoStack.add(undoInfoA.merge(undoInfoB));
}
@Override
public GridElementDeprecatedAddons getDeprecatedAddons() {
return GridElementDeprecatedAddons.NONE;
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/UndoHistory.java 0000644 0001750 0001750 00000002262 12533641120 026050 0 ustar ben ben package com.baselet.element;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
public class UndoHistory {
private final Logger log = Logger.getLogger(UndoHistory.class);
private final List history = new ArrayList();
private int currentIndex = -1;
public void add(UndoInformation undoInformation) {
while (history.size() > currentIndex + 1) {
history.remove(history.size() - 1);
}
history.add(undoInformation);
currentIndex++;
}
public UndoInformation remove() {
UndoInformation undoInformation = history.remove(currentIndex);
currentIndex = Math.min(currentIndex, history.size() - 1); // stay at current index except if it was pointing to the last element
return undoInformation;
}
public UndoInformation get(boolean undo) {
if (history.isEmpty()) {
return null;
}
if (!undo) {
currentIndex++;
}
UndoInformation undoInformation = history.get(currentIndex);
log.trace("GET " + currentIndex + " = " + undoInformation.getDiffRectangle(10, undo) + "/size" + history.size());
if (undo) {
currentIndex--;
}
return undoInformation;
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/UndoInformation.java 0000644 0001750 0001750 00000013072 12533641120 026675 0 ustar ben ben package com.baselet.element;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Map.Entry;
import com.baselet.control.SharedUtils;
import com.baselet.control.basics.geom.Rectangle;
import com.baselet.control.constants.SharedConstants;
import com.baselet.element.sticking.PointChange;
import com.baselet.element.sticking.Stickable;
public class UndoInformation {
private final Rectangle diffRect;
private final Map> stickableMoves;
private final String oldAdditionalAttributes;
private final String newAdditionalAttributes;
private UndoInformation(Rectangle diffRect, Map> stickableMoves, String oldAdditionalAttributes, String newAdditionalAttributes) {
this.diffRect = diffRect;
this.stickableMoves = stickableMoves;
this.oldAdditionalAttributes = oldAdditionalAttributes;
this.newAdditionalAttributes = newAdditionalAttributes;
}
public UndoInformation(Rectangle newRect, Rectangle oldRect, Map> stickableMoves, int gridSize, String oldAdditionalAttributes, String newAdditionalAttributes) {
this(toMinZoom(newRect.subtract(oldRect), gridSize), stickableMoves, oldAdditionalAttributes, newAdditionalAttributes);
}
private static Map> invertStickableMoves(Map> stickableMoves) {
Map> invertedMap = new HashMap>();
for (Entry> entry : stickableMoves.entrySet()) {
List invList = new ArrayList();
for (PointChange p : entry.getValue()) {
invList.add(new PointChange(p.getIndex(), -p.getDiffX(), -p.getDiffY()));
}
invertedMap.put(entry.getKey(), invList);
}
return invertedMap;
}
public Rectangle getDiffRectangle(int gridSize, boolean undo) {
Rectangle returnRect = undo ? diffRect.copyInverted() : diffRect;
return toCurrentZoom(returnRect, gridSize);
}
public Map> getStickableMoves(boolean undo) {
return undo ? invertStickableMoves(stickableMoves) : stickableMoves;
}
public String getAdditionalAttributes(boolean undo) {
if (undo) {
return oldAdditionalAttributes;
}
else {
return newAdditionalAttributes;
}
}
private static Rectangle toMinZoom(Rectangle rectangle, int gridSize) {
int xBefore = toMinZoom(rectangle.getX(), gridSize);
int yBefore = toMinZoom(rectangle.getY(), gridSize);
int wBefore = toMinZoom(rectangle.getWidth(), gridSize);
int hBefore = toMinZoom(rectangle.getHeight(), gridSize);
return new Rectangle(xBefore, yBefore, wBefore, hBefore);
}
private static int toMinZoom(int val, int gridSize) {
return val / gridSize;
}
private static Rectangle toCurrentZoom(Rectangle rectangle, int gridSize) {
int xBefore = toCurrentZoom(rectangle.getX(), gridSize);
int yBefore = toCurrentZoom(rectangle.getY(), gridSize);
int wBefore = toCurrentZoom(rectangle.getWidth(), gridSize);
int hBefore = toCurrentZoom(rectangle.getHeight(), gridSize);
return new Rectangle(xBefore, yBefore, wBefore, hBefore);
}
private static int toCurrentZoom(int val, int gridSize) {
return val * gridSize;
}
public UndoInformation merge(UndoInformation other) {
Rectangle mergedUndoDiffRect = diffRect.add(other.diffRect);
Map> mergedMap = new HashMap>();
mergeStickableMoves(mergedMap, stickableMoves);
mergeStickableMoves(mergedMap, other.stickableMoves);
return new UndoInformation(mergedUndoDiffRect, mergedMap, other.oldAdditionalAttributes, newAdditionalAttributes);
}
private void mergeStickableMoves(Map> targetMap, Map> sourceMap) {
for (Entry> sourceEntry : sourceMap.entrySet()) {
Stickable sourceStickable = sourceEntry.getKey();
List sourceChangeList = sourceEntry.getValue();
List targetPointChanges = targetMap.get(sourceStickable);
if (targetPointChanges == null) { // stickable was not moved before in targetMap
targetMap.put(sourceStickable, sourceChangeList);
}
else { // stickable was already moved and these moves must be merged
mergeSourceToTarget(sourceChangeList, targetPointChanges);
}
}
}
private void mergeSourceToTarget(List sourceChangeList, List targetPointChanges) {
for (PointChange sourceChange : sourceChangeList) {
mergePoint(targetPointChanges, sourceChange);
}
}
private void mergePoint(List targetPointChanges, PointChange sourceChange) {
for (ListIterator iter = targetPointChanges.listIterator(); iter.hasNext();) {
PointChange targetChange = iter.next();
if (sourceChange.getIndex().equals(targetChange.getIndex())) {
iter.set(new PointChange(targetChange.getIndex(), sourceChange.getDiffX() + targetChange.getDiffX(), sourceChange.getDiffY() + targetChange.getDiffY()));
return; // index already in targetList and successfully updated
}
}
targetPointChanges.add(sourceChange); // index not in targetList, therefore added here
}
public String toString(boolean undo) {
return "UndoInformation [diffRect=" + getDiffRectangle(SharedConstants.DEFAULT_GRID_SIZE, undo) + ", stickableMoves=" + SharedUtils.mapToString(getStickableMoves(undo)) + ", additionalAttributes=" + getAdditionalAttributes(undo) + "]";
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/interfaces/ 0000755 0001750 0001750 00000000000 12533641120 025037 5 ustar ben ben ././@LongLink 0000644 0000000 0000000 00000000161 00000000000 011601 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/interfaces/GridElementDeprecatedAddons.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/interfaces/GridElementDeprecate0000644 0001750 0001750 00000000415 12533641120 030776 0 ustar ben ben package com.baselet.element.interfaces;
public interface GridElementDeprecatedAddons {
void doBeforeExport();
public static final GridElementDeprecatedAddons NONE = new GridElementDeprecatedAddons() {
@Override
public void doBeforeExport() {}
};
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/interfaces/Component.java 0000644 0001750 0001750 00000000566 12533641120 027653 0 ustar ben ben package com.baselet.element.interfaces;
import com.baselet.control.basics.geom.Rectangle;
import com.baselet.diagram.draw.DrawHandler;
public interface Component {
void setBoundsRect(Rectangle rect);
Rectangle getBoundsRect();
void repaintComponent();
DrawHandler getDrawHandler();
DrawHandler getMetaDrawHandler();
void afterModelUpdate();
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/interfaces/GridElement.java 0000644 0001750 0001750 00000004177 12533641120 030112 0 ustar ben ben package com.baselet.element.interfaces;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import com.baselet.control.basics.geom.Dimension;
import com.baselet.control.basics.geom.Point;
import com.baselet.control.basics.geom.Rectangle;
import com.baselet.control.enums.Direction;
import com.baselet.control.enums.ElementId;
import com.baselet.element.sticking.StickableMap;
import com.baselet.element.sticking.StickingPolygon;
public interface GridElement extends HasPanelAttributes {
void setRectangle(Rectangle bounds);
Integer getGroup();
void setLocationDifference(int diffx, int diffy);
String getAdditionalAttributes();
void setAdditionalAttributes(String additionalAttributes);
void setLocation(int x, int y);
void setSize(int width, int height);
Set getResizeArea(int x, int y);
StickingPolygon generateStickingBorder(Rectangle rect);
StickingPolygon generateStickingBorder();
/**
* position of the element on the drawpanel.
* x and y: distance from the upper left corner of the drawpanel.
* width and height: size of the element.
*
*/
Rectangle getRectangle();
void repaint();
/**
* @return size of the element as if the zoomlevel would be 100% (eg: if zoom is 80% and width is 80 it would be returned as 100)
*/
Dimension getRealSize();
boolean isInRange(Rectangle rectangle);
Component getComponent();
void setProperty(String key, Object newValue);
void updateModelFromText();
String getSetting(String key);
Integer getLayer();
ElementId getId();
void drag(Collection resizeDirection, int diffX, int diffY, Point mousePosBeforeDrag, boolean isShiftKeyDown, boolean firstDrag, StickableMap stickables, boolean undoable);
boolean isSelectableOn(Point point);
void dragEnd();
List getPanelAttributesAsList();
void setRectangleDifference(int diffx, int diffy, int diffw, int diffh, boolean firstDrag, StickableMap stickables, boolean undoable);
void undoDrag();
void redoDrag();
void mergeUndoDrag();
GridElementDeprecatedAddons getDeprecatedAddons();
}
././@LongLink 0000644 0000000 0000000 00000000150 00000000000 011577 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/interfaces/HasPanelAttributes.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/interfaces/HasPanelAttributes.j0000644 0001750 0001750 00000000453 12533641120 030756 0 ustar ben ben package com.baselet.element.interfaces;
import java.util.List;
import com.baselet.gui.AutocompletionText;
public interface HasPanelAttributes {
String getPanelAttributes();
void setPanelAttributes(String panelAttributes);
List getAutocompletionList();
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/interfaces/Diagram.java 0000644 0001750 0001750 00000001247 12533641120 027252 0 ustar ben ben package com.baselet.element.interfaces;
import java.util.Collection;
import java.util.List;
import com.baselet.element.sticking.Stickable;
import com.baselet.element.sticking.StickableMap;
public interface Diagram extends HasPanelAttributes, HasGridElements {
public abstract List getStickables();
public abstract StickableMap getStickables(GridElement draggedElement);
public abstract StickableMap getStickables(GridElement draggedElement, Collection excludeList);
public abstract List getGridElementsByLayerLowestToHighest();
public abstract List getGridElementsByLayer(boolean ascending);
}
././@LongLink 0000644 0000000 0000000 00000000152 00000000000 011601 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/interfaces/DrawHandlerInterface.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/interfaces/DrawHandlerInterface0000644 0001750 0001750 00000000406 12533641120 030776 0 ustar ben ben package com.baselet.element.interfaces;
import com.baselet.element.sticking.StickableMap;
public interface DrawHandlerInterface {
void updatePropertyPanel();
int getGridSize();
StickableMap getStickableMap();
boolean isInitialized();
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/interfaces/HasGridElements.java0000644 0001750 0001750 00000000230 12533641120 030713 0 ustar ben ben package com.baselet.element.interfaces;
import java.util.List;
public interface HasGridElements {
public List getGridElements();
} umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/ 0000755 0001750 0001750 00000000000 12533641120 025057 5 ustar ben ben umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/ElementFactory.java 0000644 0001750 0001750 00000004316 12533641120 030647 0 ustar ben ben package com.baselet.element.elementnew;
import com.baselet.control.enums.ElementId;
import com.baselet.element.NewGridElement;
import com.baselet.element.elementnew.plot.PlotGrid;
import com.baselet.element.elementnew.uml.ActivityObject;
import com.baselet.element.elementnew.uml.Actor;
import com.baselet.element.elementnew.uml.Class;
import com.baselet.element.elementnew.uml.Deployment;
import com.baselet.element.elementnew.uml.Frame;
import com.baselet.element.elementnew.uml.Generic;
import com.baselet.element.elementnew.uml.Hierarchy;
import com.baselet.element.elementnew.uml.Interface;
import com.baselet.element.elementnew.uml.Note;
import com.baselet.element.elementnew.uml.Package;
import com.baselet.element.elementnew.uml.SpecialState;
import com.baselet.element.elementnew.uml.State;
import com.baselet.element.elementnew.uml.SyncBarHorizontal;
import com.baselet.element.elementnew.uml.SyncBarVertical;
import com.baselet.element.elementnew.uml.Timer;
import com.baselet.element.elementnew.uml.UseCase;
import com.baselet.element.relation.Relation;
public abstract class ElementFactory {
protected static NewGridElement createAssociatedGridElement(ElementId id) {
switch (id) {
case PlotGrid:
return new PlotGrid();
case Relation:
return new Relation();
case Text:
return new Text();
case UMLActor:
return new Actor();
case UMLClass:
return new Class();
case UMLDeployment:
return new Deployment();
case UMLFrame:
return new Frame();
case UMLGeneric:
return new Generic();
case UMLInterface:
return new Interface();
case UMLNote:
return new Note();
case UMLObject:
return new ActivityObject();
case UMLPackage:
return new Package();
case UMLSpecialState:
return new SpecialState();
case UMLState:
return new State();
case UMLSyncBarHorizontal:
return new SyncBarHorizontal();
case UMLSyncBarVertical:
return new SyncBarVertical();
case UMLTimer:
return new Timer();
case UMLUseCase:
return new UseCase();
case UMLHierarchy:
return new Hierarchy();
default:
throw new RuntimeException("Unknown class id: " + id);
}
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/Text.java 0000644 0001750 0001750 00000001330 12533641120 026643 0 ustar ben ben package com.baselet.element.elementnew;
import com.baselet.control.enums.ElementId;
import com.baselet.element.NewGridElement;
import com.baselet.element.facet.PropertiesParserState;
import com.baselet.element.facet.Settings;
import com.baselet.element.settings.SettingsText;
import com.baselet.element.sticking.polygon.NoStickingPolygonGenerator;
public class Text extends NewGridElement {
@Override
protected Settings createSettings() {
return new SettingsText();
}
@Override
public ElementId getId() {
return ElementId.Text;
}
@Override
protected void drawCommonContent(PropertiesParserState state) {
state.setStickingPolygonGenerator(NoStickingPolygonGenerator.INSTANCE);
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/ 0000755 0001750 0001750 00000000000 12533641120 026035 5 ustar ben ben umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/parser/ 0000755 0001750 0001750 00000000000 12533641120 027331 5 ustar ben ben ././@LongLink 0000644 0000000 0000000 00000000161 00000000000 011601 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/parser/ParserException.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/parser/ParserEx0000644 0001750 0001750 00000001506 12533641120 031007 0 ustar ben ben package com.baselet.element.elementnew.plot.parser;
import java.util.Arrays;
public class ParserException extends RuntimeException {
private static final long serialVersionUID = 1L;
public ParserException() {
super("Unknown Error");
}
public ParserException(String message) {
super(message);
}
public ParserException(String key, String value, int line) {
this("Invalid assignment: \"" + key + "=" + value + "\" (line: " + line + ")");
}
public ParserException(String key, String value, int line, String additionalInfo) {
this("Invalid assignment: \"" + key + "=" + value + "\" (line: " + line + ") [" + additionalInfo + "]");
}
public ParserException(String key, String[] values, int line) {
this("The following values are colliding: \"" + key + "=" + Arrays.asList(values) + "\" (line: " + line + ")");
}
}
././@LongLink 0000644 0000000 0000000 00000000152 00000000000 011601 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/parser/KeyValue.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/parser/KeyValue0000644 0001750 0001750 00000001500 12533641120 030775 0 ustar ben ben package com.baselet.element.elementnew.plot.parser;
public class KeyValue {
private String key;
private String value;
private int line;
private boolean used;
public KeyValue(String key, String value, int line) {
super();
this.key = key;
this.value = value;
this.line = line;
used = false;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public int getLine() {
return line;
}
public void setLine(int line) {
this.line = line;
}
public boolean isUsed() {
return used;
}
public void setUsed(boolean used) {
this.used = used;
}
@Override
public String toString() {
return key + "\t-> " + value + " (line " + line + ")";
}
}
././@LongLink 0000644 0000000 0000000 00000000157 00000000000 011606 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/parser/PlotConstants.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/parser/PlotCons0000644 0001750 0001750 00000017537 12533641120 031032 0 ustar ben ben package com.baselet.element.elementnew.plot.parser;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.baselet.gui.AutocompletionText;
public class PlotConstants {
/** Shared Value Constants **/
// Some key->value assignments have a list as value and the following separator is used to separate the list entries
public static final String VALUE_LIST_SEPARATOR = ",";
public static final String KEY_VALUE_SEP = "=";
// If a variable is set to DEFAULT_VALUE, it gets removed from the parsers plotValuesCache, therefore the DEFAULT is used again
public static final String DEFAULT_VALUE = "auto";
/** Parser Constants **/
public static final String PLOT = "plot";
public static final String DATA = "data";
public static final String REGEX_COMMENT = "(//.*)";
public static final String REGEX_KEY = "([(\\w)\\.]+)";
// a value is a comma separated list of word characters or "-" (for negative int eg: min_val=-3) or # (for color decoding) or . (for hierarchies)
public static final String REGEX_VALUE = "([-(\\w)#\\." + VALUE_LIST_SEPARATOR + "]*)";
public static final String REGEX_VALUE_ASSIGNMENT = "(" + REGEX_KEY + KEY_VALUE_SEP + REGEX_VALUE + ")";
// plot followed by an optional space or plot followed by 1 or more value assignments (values which are only valid for the plot)
public static final String REGEX_PLOT = "((" + PLOT + " ?)|(" + PLOT + " (" + REGEX_VALUE_ASSIGNMENT + " )*" + REGEX_VALUE_ASSIGNMENT + "))";
// +plot (overlap plots) followed by an optional space or plot followed by 1 or more value assignments (values which are only valid for the plot)
public static final String REGEX_PLOT_ADD = "(\\+" + REGEX_PLOT + ")";
// data followed by an optional space or by space and a name which consists of word characters
public static final String REGEX_DATA = "((" + DATA + " ?)|(" + DATA + " (\\w)+))";
// 1 non-comment-line which contains at least 1 Tab is an interpreted dataset
public static final String REGEX_DATA_SEPARATOR = "([\t ]+)";
public static final String REGEX_DATA_GUESS = "((?!(" + REGEX_COMMENT + "))(([^=]+)|(.*" + REGEX_DATA_SEPARATOR + ".*)))";
// The following line is needed to color everything which doesn't match another RegEx
// public static final String REGEX_COLOR_BASE = "(?!((" + REGEX_COMMENT + ")|(" + PLOT + ")|(" + REGEX_VALUE_ASSIGNMENT + "))).*";
/* The following variables are automatically parsed for the autocompletion. Therefore some conventions must be made: 1.) The possible values of a key must be listed in the following lines or they will not be recognized by the autocompletion 2.) Every key is separated in 3 parts: KEY__. can be STRING,INT,LIST,BOOL (in future there may be more types) 3.) If there is a limited number of possible values it must be named: _ where must match the tag in the key 4.) values with _DEFAULT at the end are ignored by the autocompletion. */
/** Plotgrid Value Constants **/
public static final String KEY_INT_GRID_WIDTH = "grid.width";
public static final String GRID_WIDTH_DEFAULT = "3";
/** Plot Value Constants **/
public static final String KEY_BOOL_DATA_INVERT = "data.invert";
public static final Boolean DATA_INVERT_DEFAULT = false;
public static final String KEY_BOOL_PLOT_TILT = "tilt";
public static final Boolean PLOT_TILT_DEFAULT = false;
public static final String KEY_INT_X_POSITION = "pos.x"; // DEFAULT: filling grid from upper left to lower right corner
public static final String KEY_INT_Y_POSITION = "pos.y";
public static final String KEY_INT_MIN_VALUE = "value.min"; // DEFAULT: the lowest/highest value in the plot
public static final String MIN_VALUE_ALL = "all";
public static final String KEY_INT_MAX_VALUE = "value.max";
public static final String MAX_VALUE_ALL = "all";
public static final String KEY_LIST_COLORS = "colors"; // DEFAULT: cycling through colors-list
public static final List COLORS_DEFAULT = Arrays.asList("red", "blue", "green", "orange", "cyan", "magenta", "pink");
public static interface PlotSetting {
public String getValue();
}
public static enum PlotType implements PlotSetting {
Bar, Line, Pie, Scatter;
@Override
public String getValue() {
return toString().toLowerCase();
}
public static String getKey() {
return "type";
}
}
public static enum AxisShow implements PlotSetting {
Axis, Line, Marker, Text, Nothing("");
private final String value;
AxisShow() {
value = toString().toLowerCase();
}
public static String getValueList() {
return KEY_VALUE_SEP + AxisShow.Axis.getValue() + VALUE_LIST_SEPARATOR + AxisShow.Line.getValue() + VALUE_LIST_SEPARATOR + AxisShow.Marker.getValue() + VALUE_LIST_SEPARATOR + AxisShow.Text.getValue();
}
AxisShow(String value) {
this.value = value;
}
@Override
public String getValue() {
return value;
}
public static String getKeyValueAxis() {
return "axis.value.show";
}
public static String getKeyDescAxis() {
return "axis.desc.show";
}
}
public static enum AxisList implements PlotSetting {
Relevant, Nothing("");
private final String value;
AxisList() {
value = toString().toLowerCase();
}
AxisList(String value) {
this.value = value;
}
@Override
public String getValue() {
return value;
}
public static String getKey() {
return "axis.value.list";
}
}
public static List toStringList(PlotSetting[] input) {
return toStringList(Arrays.asList(input));
}
public static List toStringList(List extends PlotSetting> input) {
List returnList = new ArrayList();
for (PlotSetting o : input) {
returnList.add(o.getValue());
}
return returnList;
}
public static final List AUTOCOMPLETION_LIST = Arrays.asList(
new AutocompletionText(PLOT, "draws the configured plot"),
new AutocompletionText(DATA, "marks everything until the next empty line as dataset"),
new AutocompletionText(DATA + KEY_VALUE_SEP + "", "as data but with explicit name"),
new AutocompletionText(KEY_INT_GRID_WIDTH + KEY_VALUE_SEP + GRID_WIDTH_DEFAULT, "sets the amount of plots per line"),
new AutocompletionText(KEY_BOOL_DATA_INVERT + KEY_VALUE_SEP + DATA_INVERT_DEFAULT, "inverts the dataset"),
new AutocompletionText(KEY_BOOL_PLOT_TILT + KEY_VALUE_SEP + PLOT_TILT_DEFAULT, "tilts the plot"),
new AutocompletionText(KEY_INT_X_POSITION + KEY_VALUE_SEP + "", "places the next plot at specific horizontal grid position"),
new AutocompletionText(KEY_INT_Y_POSITION + KEY_VALUE_SEP + "", "places the next plot at specific vertical grid position"),
new AutocompletionText(KEY_INT_MIN_VALUE + KEY_VALUE_SEP + MIN_VALUE_ALL, "restrict the highest value shown in the plot"),
new AutocompletionText(KEY_INT_MAX_VALUE + KEY_VALUE_SEP + MAX_VALUE_ALL, "restrict the lowest value shown in the plot"),
new AutocompletionText(KEY_LIST_COLORS + KEY_VALUE_SEP + COLORS_DEFAULT.get(0) + VALUE_LIST_SEPARATOR + COLORS_DEFAULT.get(1), "sets a list of colors which will be cycled by the plot"),
new AutocompletionText(PlotType.getKey() + KEY_VALUE_SEP + PlotType.Bar.getValue(), "sets the plot type to Bar plot"),
new AutocompletionText(PlotType.getKey() + KEY_VALUE_SEP + PlotType.Line.getValue(), "sets the plot type to Line plot"),
new AutocompletionText(PlotType.getKey() + KEY_VALUE_SEP + PlotType.Pie.getValue(), "sets the plot type to Pie plot"),
new AutocompletionText(PlotType.getKey() + KEY_VALUE_SEP + PlotType.Scatter.getValue(), "sets the plot type to Scatter plot"),
new AutocompletionText(AxisShow.getKeyValueAxis() + AxisShow.getValueList(), "a list of elements to show at the value axis"),
new AutocompletionText(AxisShow.getKeyDescAxis() + AxisShow.getValueList(), "a list of elements to show at the description axis"),
new AutocompletionText(AxisList.getKey() + KEY_VALUE_SEP + AxisList.Relevant.getValue(), "restricts shown values to occurring ones")
);
}
././@LongLink 0000644 0000000 0000000 00000000151 00000000000 011600 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/parser/DataSet.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/parser/DataSet.0000644 0001750 0001750 00000012140 12533641120 030655 0 ustar ben ben package com.baselet.element.elementnew.plot.parser;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.baselet.control.Matrix;
public class DataSet {
private String id;
private Integer nr;
private int lineNr;
private boolean isInverted;
private List titleRow = null;
private List titleCol = null;
private Matrix valueMatrix;
private Matrix analyseMatrix;
public static final Double VALUE_DEFAULT = 0.0; // used for invalid value fields or missing fields
protected DataSet(String id, int nr, int lineNr) {
this.id = id;
this.nr = nr;
this.lineNr = lineNr;
analyseMatrix = new Matrix();
}
public String getId() {
return id;
}
public Integer getNr() {
return nr;
}
public int getLineNr() {
return lineNr;
}
/**
* @return the row size
*/
public int rows() {
return valueMatrix.rows();
}
/**
* @return the column size
*/
public int cols() {
return valueMatrix.cols();
}
public boolean isEmpty() {
return valueMatrix.isEmpty();
}
/**
* @param index
* the index of the row
* @return a Double[] containing the cells of the row
*/
public Double[] row(int index) {
List list = valueMatrix.row(index);
return list.toArray(new Double[list.size()]);
}
public Double[][] data() {
if (valueMatrix.isEmpty()) {
throw new ParserException("The dataset (line: " + getLineNr() + ") has no values");
}
Double[][] returnArray = new Double[rows()][];
for (int i = 0; i < rows(); i++) {
returnArray[i] = row(i);
}
return returnArray;
}
/**
* Changed the manual inversion of the dataset. The dataset must only be inverted if the value has changed because
* it is only referenced from plots, therefore the last inversion will be dragged to further plot-calls without a problem
*/
public void setInvert(boolean shouldBeInverted) {
if (isInverted == !shouldBeInverted) {
analyseMatrix.invert();
separateTitleRowColFromContent();
isInverted = shouldBeInverted;
}
}
public String[] titleRow() {
return titleRow.toArray(new String[titleRow.size()]);
}
public String[] titleCol() {
return titleCol.toArray(new String[titleCol.size()]);
}
@Override
public String toString() {
return "Dataset (" + id + ")\n" + analyseMatrix;
}
protected void addLine(String[] line) {
analyseMatrix.addLine(new ArrayList(Arrays.asList(line)));
}
protected void analyseMatrix() {
separateTitleRowColFromContent();
// If the valuematrix has more rows than cols the analyseMatrix must be inverted and analysed again
// if (!valueMatrix.isEmpty() && valueMatrix.hasMoreRowsThanCols()) analyseMatrix.invert();
// separateTitleRowColFromContent();
}
private void separateTitleRowColFromContent() {
if (analyseMatrix.isEmpty()) {
throw new ParserException("The dataset (line: " + getLineNr() + ") has no content");
}
List firstRow = analyseMatrix.row(0);
List firstCol = analyseMatrix.col(0);
boolean hasTitleRow = isTitleLine(firstRow);
boolean hasTitleCol = isTitleLine(firstCol);
if (hasTitleRow && hasTitleCol) {
if (!firstRow.get(0).isEmpty() || !firstCol.get(0).isEmpty()) {
throw new ParserException("If a dataset has a title row and column, the upper left space must be empty");
}
titleRow = firstRow.subList(1, firstRow.size()); // ignore first cell
titleCol = firstCol.subList(1, firstCol.size()); // ignore first cell
}
else if (hasTitleRow && !hasTitleCol) {
titleRow = firstRow;
titleCol = createEmptyList(firstCol.size() - 1);
}
else if (!hasTitleRow && hasTitleCol) {
titleRow = createEmptyList(firstRow.size() - 1);
titleCol = firstCol;
}
else /* if (!hasTitleRow && !hasTitleCol) */{
titleRow = createEmptyList(firstRow.size());
titleCol = createEmptyList(firstCol.size());
}
valueMatrix = new Matrix();
for (int r = hasTitleRow ? 1 : 0; r < analyseMatrix.rows(); r++) {
List row = analyseMatrix.row(r);
List rowDouble = new ArrayList();
for (int c = hasTitleCol ? 1 : 0; c < row.size(); c++) {
String val = row.get(c);
try {
if (val == null) {
throw new NumberFormatException();
}
else {
rowDouble.add(Double.parseDouble(val));
}
} catch (NumberFormatException ex) {
throw new ParserException("The Dataset (line: " + getLineNr() + ") contains invalid values");
}
}
valueMatrix.addLine(rowDouble);
}
}
private boolean isTitleLine(List row) {
int numbersInRow = 0;
for (String cell : row) {
if (cell == null) {
continue;
}
try {
Double.parseDouble(cell);
numbersInRow++;
} catch (NumberFormatException ex) {/* do nothing */}
}
return row.size() - numbersInRow > numbersInRow;
}
private List createEmptyList(int size) {
List returnList = new ArrayList();
for (int i = 0; i < size; i++) {
returnList.add("");
}
return returnList;
}
}
././@LongLink 0000644 0000000 0000000 00000000156 00000000000 011605 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/parser/ParserResult.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/parser/ParserRe0000644 0001750 0001750 00000003721 12533641120 031002 0 ustar ben ben package com.baselet.element.elementnew.plot.parser;
import java.util.ArrayList;
import java.util.HashMap;
import com.baselet.diagram.draw.DrawHandler;
public class ParserResult {
private DrawHandler drawer;
private final ArrayList plotStateList;
// These are few variables which influence the plotgrid
private final HashMap plotGridValues;
public ParserResult() {
plotStateList = new ArrayList();
plotGridValues = new HashMap();
}
public void setDrawer(DrawHandler drawer) {
this.drawer = drawer;
}
public DrawHandler getDrawer() {
return drawer;
}
public ArrayList getPlotStateList() {
return plotStateList;
}
public String getPlotGridValue(String key, String defaultValue) {
KeyValue keyValue = plotGridValues.get(key);
if (keyValue != null) {
keyValue.setUsed(true);
}
if (keyValue == null || keyValue.getValue().equals(PlotConstants.DEFAULT_VALUE)) {
return defaultValue;
}
else {
return keyValue.getValue();
}
}
protected void addPlotState(PlotState plotState) {
plotStateList.add(plotState);
}
protected void addPlotGridValue(String key, KeyValue value) {
plotGridValues.put(key, value);
}
protected void removePlotGridValue(String key) {
plotGridValues.remove(key);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("\n-----------------------------\n");
sb.append("--------PARSER CONTENT-------\n");
sb.append("-----------------------------\n\n");
sb.append("##########PlotStates#########\n\n");
for (PlotState plotState : plotStateList) {
sb.append(plotState.toString()).append("\n");
}
sb.append("#########PlotGridValues########\n\n");
for (String key : plotGridValues.keySet()) {
sb.append("\t").append(key).append(" -> ").append(plotGridValues.get(key)).append("\n");
}
sb.append("\n-----------------------------\n");
sb.append("-----------------------------\n");
return sb.toString();
}
}
././@LongLink 0000644 0000000 0000000 00000000150 00000000000 011577 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/parser/Parser.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/parser/Parser.j0000644 0001750 0001750 00000017763 12533641120 030756 0 ustar ben ben package com.baselet.element.elementnew.plot.parser;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Map.Entry;
import org.apache.log4j.Logger;
public class Parser {
private static final Logger log = Logger.getLogger(Parser.class);
// The parserResult contains every information which is relevant after input parsing is finished
private final ParserResult parserResult;
// The following fields are only used during parsing but never referenced after parsing is finished
// The values HashsMap contains the actual state of key->value assignments which is copied to every plot at its time of creation
private final HashMap tempPlotValuesCache;
// The datasetNr is used for sequential naming of not explicitly named datasets
private int datasetNr = 1;
// The datasetlist is filled during parsing. After parsing every plot gets its dataset injected
private final ArrayList datasetList;
public Parser() {
parserResult = new ParserResult();
datasetList = new ArrayList();
tempPlotValuesCache = new HashMap();
}
public ParserResult parse(String source) {
List inputList = Arrays.asList(source.split("\n", -1));
ListIterator inputIterator = inputList.listIterator();
while (inputIterator.hasNext()) {
String line = inputIterator.next();
if (line.isEmpty() || line.matches(PlotConstants.REGEX_COMMENT)) {/* ignore empty lines and comments */}
else if (line.matches(PlotConstants.REGEX_PLOT)) {
parserResult.addPlotState(createPlotStateObject(line.split(" "), inputIterator));
}
else if (line.matches(PlotConstants.REGEX_PLOT_ADD)) {
List plotStates = parserResult.getPlotStateList();
if (plotStates.isEmpty()) {
// if no plotStates, create a new one
parserResult.addPlotState(createPlotStateObject(line.split(" "), inputIterator));
}
else {
// if plots exist, add new plotState to last plotState
PlotState last = plotStates.get(plotStates.size() - 1);
last.addSubPlot(createPlotStateObject(line.split(" "), inputIterator));
}
}
else if (line.matches(PlotConstants.REGEX_DATA)) {
createDatasetObject(line.split(" "), inputIterator);
}
else if (line.matches(PlotConstants.REGEX_DATA_GUESS)) {
inputIterator.previous(); // Must go 1 step back to avoid skipping the first line in createDatasetObject
createDatasetObject(new String[] { PlotConstants.DATA }, inputIterator);
}
else if (line.matches(PlotConstants.REGEX_VALUE_ASSIGNMENT)) {
createKeyValueAssignment(line, inputIterator.nextIndex());
}
else {
throw new ParserException("Invalid line: " + line + "(line: " + inputIterator.nextIndex() + ")");
}
}
analyseDatasets();
addDatasetsToPlotStates();
return parserResult;
}
/**
* Is called after parsing everything to analyse the dataset content
*/
private void analyseDatasets() {
for (DataSet dataset : datasetList) {
dataset.analyseMatrix();
}
}
/**
* Is called after parsing everything to fill datasets in each plotState Object
*/
private void addDatasetsToPlotStates() {
if (datasetList.isEmpty()) {
throw new ParserException("You must specify at least one dataset.");
}
int actualAutoDatasetNr = 0;
for (PlotState plotState : parserResult.getPlotStateList()) {
actualAutoDatasetNr = addDataset(plotState, actualAutoDatasetNr);
// also add datasets to subplots
for (PlotState subPlotState : plotState.getSubplots()) {
log.info("Add dataset for subplot");
actualAutoDatasetNr = addDataset(subPlotState, actualAutoDatasetNr);
}
}
}
private int addDataset(PlotState plotState, int actualAutoDatasetNr) {
String datasetId = plotState.getValue(PlotConstants.DATA, null);
if (datasetId == null) {
if (actualAutoDatasetNr >= datasetList.size()) {
actualAutoDatasetNr = 0;
}
plotState.setDataSet(datasetList.get(actualAutoDatasetNr++));
}
else {
DataSet dataset = null;
if (datasetId.startsWith("#")) {
String datasetNr = datasetId.substring(1);
for (DataSet tempDataset : datasetList) {
if (datasetNr.equals(String.valueOf(tempDataset.getNr()))) {
dataset = tempDataset;
}
}
}
else {
for (DataSet tempDataset : datasetList) {
if (datasetId.equals(tempDataset.getId())) {
dataset = tempDataset;
}
}
}
if (dataset != null) {
plotState.setDataSet(dataset);
}
else {
throw new ParserException(PlotConstants.DATA, datasetId, plotState.getLine(PlotConstants.DATA));
}
}
return actualAutoDatasetNr;
}
/**
* Creates a dataset with the second argument as its id (if it has no such parameter it gets a generated id)
* This method is called if the input string starts with "data" or if the input string contains a tab (then a dataset is assumed)
* All lines until the next empty line are part of the dataset
*
* @param args any parameters to the data command including the command itself as first parameter
*/
private void createDatasetObject(String[] args, ListIterator inputIterator) {
int lineNr = inputIterator.nextIndex();
String datasetId = null;
if (args != null) {
if (args.length > 1) {
datasetId = args[1];
/* handle further parameters here */
}
}
DataSet newDataset = new DataSet(datasetId, datasetNr++, lineNr);
while (inputIterator.hasNext()) {
String nextLine = inputIterator.next();
if (nextLine.matches(PlotConstants.REGEX_COMMENT)) {
continue;
}
else if (nextLine.trim().isEmpty()) {
break;
}
else {
newDataset.addLine(nextLine.split(PlotConstants.REGEX_DATA_SEPARATOR));
}
}
if (datasetId != null) {
for (DataSet ds : datasetList) {
if (datasetId.equals(ds.getId())) {
throw new ParserException("The dataset name \"" + datasetId + "\" (line: " + lineNr + ") already exists");
}
}
}
datasetList.add(newDataset);
}
/**
* Creates a plotValues Object which contains the dataset as its second argument (if it has no such parameter it cycles through all datasets)
* This method is called if the input string starts with "plot". All values which are stored in the parser are copied to the plot
*
* @param args any parameters to the data command including the command itself as first parameter
*/
private PlotState createPlotStateObject(String[] args, ListIterator inputIterator) {
int lineNr = inputIterator.nextIndex();
HashMap localCopyOfValuesCache = copyHashMap(tempPlotValuesCache);
if (args != null) {
// Arguments are handled as any other key->value assignment but are only valid for this plot
for (int i = 1; i < args.length; i++) {
String[] split = args[i].split("=");
if (split.length == 1) {
split = new String[] { split[0], "" };
}
localCopyOfValuesCache.put(split[0], new KeyValue(split[0], split[1], lineNr));
}
}
// If no dataset is specified the data-value is set to auto
if (localCopyOfValuesCache.get(PlotConstants.DATA) == null) {
localCopyOfValuesCache.put(PlotConstants.DATA, new KeyValue(PlotConstants.DATA, PlotConstants.DEFAULT_VALUE, lineNr));
}
PlotState newPlotState = new PlotState(lineNr, localCopyOfValuesCache);
return newPlotState;
}
/**
* Adds a key->value assignment to the values HashMap
*/
private void createKeyValueAssignment(String line, int lineNr) {
String[] split = line.split("=");
if (split.length == 1) {
split = new String[] { split[0], "" };
}
if (split[0].matches(PlotConstants.KEY_INT_GRID_WIDTH)) {
parserResult.addPlotGridValue(split[0], new KeyValue(split[0], split[1], lineNr));
}
else {
tempPlotValuesCache.put(split[0], new KeyValue(split[0], split[1], lineNr));
}
}
private HashMap copyHashMap(HashMap inputHashMap) {
HashMap returnHashMap = new HashMap();
for (Entry entry : inputHashMap.entrySet()) {
returnHashMap.put(entry.getKey(), entry.getValue());
}
return returnHashMap;
}
}
././@LongLink 0000644 0000000 0000000 00000000153 00000000000 011602 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/parser/PlotState.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/parser/PlotStat0000644 0001750 0001750 00000011424 12533641120 031030 0 ustar ben ben package com.baselet.element.elementnew.plot.parser;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
public class PlotState {
private final List subPlots;
private DataSet dataset;
private final HashMap values;
private final int plotLineNr;
protected PlotState(int plotLineNr, HashMap values) {
subPlots = new ArrayList();
this.plotLineNr = plotLineNr;
this.values = values;
}
/**
* Is only called once by the parser to calculate the dataset.
*/
protected void setDataSet(DataSet dataset) {
this.dataset = dataset;
}
public void addSubPlot(PlotState plotState) {
subPlots.add(plotState);
}
public List getSubplots() {
return subPlots;
}
public DataSet getDataSet() {
return dataset;
}
public boolean containsKey(String key) {
return values.containsKey(key);
}
public int getLine(String key) {
if (values.get(key) != null) {
return values.get(key).getLine();
}
else {
return -1;
}
}
public int getPlotLineNr() {
return plotLineNr;
}
public String getValue(String key, String defaultValue) {
KeyValue keyValue = values.get(key);
if (keyValue != null) {
keyValue.setUsed(true);
}
if (keyValue == null || keyValue.getValue().equals(PlotConstants.DEFAULT_VALUE)) {
return defaultValue;
}
else {
return keyValue.getValue();
}
}
public String getValueValidated(String key, String defaultValue, List validValues) {
String value = getValue(key, defaultValue);
if (!validValues.contains(value)) {
throw new ParserException(key, value, getLine(key));
}
return value;
}
public Double getValueAsDouble(String key, Double defaultValue) {
try {
String value = getValue(key, null);
if (value == null) {
return defaultValue;
}
else {
return Double.parseDouble(value);
}
} catch (Exception e) {
throw new ParserException(key, values.get(key).getValue(), values.get(key).getLine());
}
}
public Integer getValueAsInt(String key, Integer defaultValue) {
try {
String value = getValue(key, null);
if (value == null) {
return defaultValue;
}
else {
return Integer.parseInt(value);
}
} catch (Exception e) {
throw new ParserException(key, values.get(key).getValue(), values.get(key).getLine());
}
}
public Boolean getValueAsBoolean(String key, Boolean defaultValue) {
String value = getValue(key, null);
if (value == null) {
return defaultValue;
}
else if (value.equals("true")) {
return true;
}
else if (value.equals("false")) {
return false;
}
else {
throw new ParserException(key, values.get(key).getValue(), values.get(key).getLine());
}
}
public List getValueList(String key, List defaultValue) {
List returnArray;
String value = getValue(key, null);
if (value == null) {
returnArray = defaultValue;
}
else {
returnArray = Arrays.asList(value.split(PlotConstants.VALUE_LIST_SEPARATOR));
}
return returnArray;
}
public List getValueListValidated(String key, List defaultValue, List validValues, boolean doubleValuesAllowed) {
List valueList = getValueList(key, defaultValue);
for (String value : valueList) {
boolean intAllowedAndValueIsInt = doubleValuesAllowed && isDoubleValue(value);
if (!validValues.contains(value) && !intAllowedAndValueIsInt) {
throw new ParserException(key, value, getLine(key));
}
}
return valueList;
}
private boolean isDoubleValue(String value) {
try {
Double.parseDouble(value);
return true;
} catch (Exception e) {
return false;
}
}
/**
* Checks if all declared values are used. It throws an error for declarations which are not used by the plot (=they are invalid)
*/
public void checkIfAllValuesUsed() {
StringBuilder sb = new StringBuilder("");
for (KeyValue keyValue : values.values()) {
if (!keyValue.isUsed()) {
sb.append("\"").append(keyValue.getKey()).append("=").append(keyValue.getValue()).append("\" (line ").append(keyValue.getLine()).append(") ");
}
}
String unusedVariables = sb.toString();
if (!unusedVariables.isEmpty()) {
throw new ParserException("Invalid variables: " + unusedVariables);
}
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("");
sb.append("PlotState (").append(plotLineNr).append(")\n");
if (dataset != null) {
sb.append("\tdataset -> ").append(dataset.getLineNr()).append("\n");
}
for (KeyValue keyValue : values.values()) {
sb.append("\t").append(keyValue).append("\n");
}
if (!subPlots.isEmpty()) {
sb.append("---Begin Subplots---\n");
for (PlotState subPlot : subPlots) {
sb.append(subPlot.toString());
}
sb.append("---End Subplots---\n");
}
return sb.toString();
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/elements/ 0000755 0001750 0001750 00000000000 12533641120 027651 5 ustar ben ben ././@LongLink 0000644 0000000 0000000 00000000153 00000000000 011602 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/elements/PiePlot.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/elements/PiePlo0000644 0001750 0001750 00000002273 12533641120 030770 0 ustar ben ben package com.baselet.element.elementnew.plot.elements;
import java.util.Arrays;
import java.util.List;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.element.elementnew.plot.drawer.PlotGridDrawConfig;
import com.baselet.element.elementnew.plot.parser.PlotConstants.AxisList;
import com.baselet.element.elementnew.plot.parser.PlotConstants.AxisShow;
import com.baselet.element.elementnew.plot.parser.PlotState;
public class PiePlot extends AbstractPlot {
public PiePlot(DrawHandler drawer, PlotGridDrawConfig plotDrawConfig, PlotState plotState, int xPos, int yPos) {
super(drawer, plotDrawConfig, plotState, xPos, yPos);
}
@Override
public void plot(int columnCount, int rowCount) {
setPlotPosition(columnCount, rowCount);
plotState.checkIfAllValuesUsed();
plot.drawPiePlot();
}
@Override
protected List defaultDescAxisShow() {
return Arrays.asList();
}
@Override
protected List defaultValueAxisShow() {
return defaultDescAxisShow();
}
@Override
protected List defaultValueAxisList() {
return Arrays.asList();
}
@Override
protected int getMaxAllowedValueRows() {
return 1;
}
}
././@LongLink 0000644 0000000 0000000 00000000160 00000000000 011600 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/elements/AbstractPlot.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/elements/Abstra0000644 0001750 0001750 00000012241 12533641120 031010 0 ustar ben ben package com.baselet.element.elementnew.plot.elements;
import java.util.List;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.diagram.draw.helper.ColorOwn;
import com.baselet.diagram.draw.helper.ColorOwn.Transparency;
import com.baselet.element.elementnew.plot.drawer.AxisConfig;
import com.baselet.element.elementnew.plot.drawer.PlotDrawHandler;
import com.baselet.element.elementnew.plot.drawer.PlotGridDrawConfig;
import com.baselet.element.elementnew.plot.parser.DataSet;
import com.baselet.element.elementnew.plot.parser.ParserException;
import com.baselet.element.elementnew.plot.parser.PlotConstants;
import com.baselet.element.elementnew.plot.parser.PlotConstants.AxisList;
import com.baselet.element.elementnew.plot.parser.PlotConstants.AxisShow;
import com.baselet.element.elementnew.plot.parser.PlotState;
public abstract class AbstractPlot {
protected PlotDrawHandler plot;
protected PlotGridDrawConfig plotDrawConfig;
protected PlotState plotState;
private final Integer xPosition;
private final Integer yPosition;
public AbstractPlot(DrawHandler drawer, PlotGridDrawConfig plotDrawConfig, PlotState plotState, int xPosition, int yPosition) {
this.plotDrawConfig = plotDrawConfig;
this.plotState = plotState;
this.xPosition = xPosition;
this.yPosition = yPosition;
plot = new PlotDrawHandler(drawer, plotDrawConfig.getRealSize());
setupAxis();
setupAbstractPlot();
}
public Integer getPlotLineNr() {
return plotState.getPlotLineNr();
}
public Integer getXPosition() {
return xPosition;
}
public Integer getYPosition() {
return yPosition;
}
private void setupAxis() {
plot.getAxisConfig().enableDescAxis(
plotState.getValueListValidated(AxisShow.getKeyDescAxis(), PlotConstants.toStringList(defaultDescAxisShow()), PlotConstants.toStringList(AxisShow.values()), false));
plot.getAxisConfig().enableValueAxis(
plotState.getValueListValidated(AxisShow.getKeyValueAxis(), PlotConstants.toStringList(defaultValueAxisShow()), PlotConstants.toStringList(AxisShow.values()), false),
plotState.getValueListValidated(AxisList.getKey(), PlotConstants.toStringList(defaultValueAxisList()), PlotConstants.toStringList(AxisList.values()), true));
}
private void setupAbstractPlot() {
DataSet ds = plotState.getDataSet();
ds.setInvert(plotState.getValueAsBoolean(PlotConstants.KEY_BOOL_DATA_INVERT, PlotConstants.DATA_INVERT_DEFAULT));
String[] desc = ds.titleRow();
String[] title = ds.titleCol();
// System.out.print("\ntitle of ds " + ds.getLineNr() + " :");
// for (String t : title) System.out.print("<" + t + ">");
Double[][] values = ds.data();
List colors = plotState.getValueList(PlotConstants.KEY_LIST_COLORS, PlotConstants.COLORS_DEFAULT);
for (String color : colors) {
if (ColorOwn.forStringOrNull(color, Transparency.FOREGROUND) == null) {
throw new ParserException("Unknown color: " + color + "(line: " + plotState.getLine(PlotConstants.KEY_LIST_COLORS) + ")");
}
}
if (values.length > getMaxAllowedValueRows()) {
throw new ParserException("The dataset (line: " + plotState.getDataSet().getLineNr() + ") has too many rows for the plot (line: " + plotState.getPlotLineNr() + ")");
}
plot.setValues(desc, title, values, colors);
setMinMaxValue(PlotConstants.KEY_INT_MIN_VALUE);
setMinMaxValue(PlotConstants.KEY_INT_MAX_VALUE);
}
private void setMinMaxValue(String key) {
String stringValue = plotState.getValue(key, null);
if (stringValue != null) {
try {
if (key.equals(PlotConstants.KEY_INT_MIN_VALUE)) {
if (stringValue.equals(PlotConstants.MIN_VALUE_ALL)) {
plot.setMinValue(plotDrawConfig.getMinValue());
}
else {
plot.setMinValue(Double.valueOf(stringValue));
}
}
else if (key.equals(PlotConstants.KEY_INT_MAX_VALUE)) {
if (stringValue.equals(PlotConstants.MAX_VALUE_ALL)) {
plot.setMaxValue(plotDrawConfig.getMaxValue());
}
else {
plot.setMaxValue(Double.valueOf(stringValue));
}
}
} catch (Exception e) {
throw new ParserException(key, stringValue, plotState.getLine(key), e.getMessage());
}
}
}
protected void setPlotPosition(int columnCount, int rowCount) {
if (xPosition > columnCount) {
throw new ParserException("The x coordinate is invalid. PlotGrid width is too small");
}
if (yPosition > rowCount) {
throw new ParserException("The y coordinate is invalid. PlotGrid height is too small");
}
double segmentWidth = (double) plotDrawConfig.getRealSize().width / columnCount;
double segmentHeight = (double) plotDrawConfig.getRealSize().height / rowCount;
int spaceLeft = (int) (segmentWidth * xPosition);
int spaceRight = (int) (segmentWidth * (columnCount - xPosition - 1));
int spaceTop = (int) (segmentHeight * yPosition);
int spaceBottom = (int) (segmentHeight * (rowCount - yPosition - 1));
plot.getCanvas().setBorder(spaceLeft, spaceTop, spaceRight, spaceBottom, AxisConfig.ARROW_DISTANCE);
}
public abstract void plot(int columnCount, int rowCount);
protected abstract List defaultDescAxisShow();
protected abstract List defaultValueAxisShow();
protected abstract List defaultValueAxisList();
protected abstract int getMaxAllowedValueRows();
}
././@LongLink 0000644 0000000 0000000 00000000154 00000000000 011603 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/elements/LinePlot.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/elements/LinePl0000644 0001750 0001750 00000002764 12533641120 030770 0 ustar ben ben package com.baselet.element.elementnew.plot.elements;
import java.util.Arrays;
import java.util.List;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.element.elementnew.plot.drawer.PlotGridDrawConfig;
import com.baselet.element.elementnew.plot.parser.PlotConstants;
import com.baselet.element.elementnew.plot.parser.PlotConstants.AxisList;
import com.baselet.element.elementnew.plot.parser.PlotConstants.AxisShow;
import com.baselet.element.elementnew.plot.parser.PlotState;
public class LinePlot extends AbstractPlot {
public LinePlot(DrawHandler drawer, PlotGridDrawConfig plotDrawConfig, PlotState plotState, int xPos, int yPos) {
super(drawer, plotDrawConfig, plotState, xPos, yPos);
}
@Override
public void plot(int columnCount, int rowCount) {
setPlotPosition(columnCount, rowCount);
Boolean tilt = plotState.getValueAsBoolean(PlotConstants.KEY_BOOL_PLOT_TILT, PlotConstants.PLOT_TILT_DEFAULT);
plotState.checkIfAllValuesUsed();
plot.drawPlotAndDescValueAxis(!tilt, false, true, false);
}
@Override
protected List defaultDescAxisShow() {
return Arrays.asList(AxisShow.Axis, AxisShow.Line, AxisShow.Marker, AxisShow.Text);
}
@Override
protected List defaultValueAxisShow() {
return defaultDescAxisShow();
}
@Override
protected List defaultValueAxisList() {
return Arrays.asList(AxisList.Relevant);
}
@Override
protected int getMaxAllowedValueRows() {
return Integer.MAX_VALUE;
}
}
././@LongLink 0000644 0000000 0000000 00000000153 00000000000 011602 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/elements/BarPlot.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/elements/BarPlo0000644 0001750 0001750 00000003576 12533641120 030766 0 ustar ben ben package com.baselet.element.elementnew.plot.elements;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.element.elementnew.plot.drawer.PlotGridDrawConfig;
import com.baselet.element.elementnew.plot.parser.PlotConstants;
import com.baselet.element.elementnew.plot.parser.PlotConstants.AxisList;
import com.baselet.element.elementnew.plot.parser.PlotConstants.AxisShow;
import com.baselet.element.elementnew.plot.parser.PlotState;
public class BarPlot extends AbstractPlot {
public BarPlot(DrawHandler drawer, PlotGridDrawConfig plotDrawConfig, PlotState plotState, int xPos, int yPos) {
super(drawer, plotDrawConfig, plotState, xPos, yPos);
}
@Override
public void plot(int columnCount, int rowCount) {
setPlotPosition(columnCount, rowCount);
// The barplot should always start at 0 even if there are only values which are > 0 or only values < 0
try {
if (!plotState.containsKey(PlotConstants.KEY_INT_MIN_VALUE)) {
plot.setMinValue(0.0);
}
} catch (IOException e) {}
try {
if (!plotState.containsKey(PlotConstants.KEY_INT_MAX_VALUE)) {
plot.setMaxValue(0.0);
}
} catch (IOException e) {}
Boolean tilt = plotState.getValueAsBoolean(PlotConstants.KEY_BOOL_PLOT_TILT, PlotConstants.PLOT_TILT_DEFAULT);
plotState.checkIfAllValuesUsed();
plot.drawPlotAndDescValueAxis(!tilt, true, false, false);
}
@Override
protected List defaultDescAxisShow() {
return Arrays.asList(AxisShow.Axis, AxisShow.Marker, AxisShow.Text);
}
@Override
protected List defaultValueAxisShow() {
return Arrays.asList(AxisShow.Axis, AxisShow.Line, AxisShow.Marker, AxisShow.Text);
}
@Override
protected List defaultValueAxisList() {
return Arrays.asList(AxisList.Relevant);
}
@Override
protected int getMaxAllowedValueRows() {
return Integer.MAX_VALUE;
}
}
././@LongLink 0000644 0000000 0000000 00000000157 00000000000 011606 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/elements/ScatterPlot.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/elements/Scatte0000644 0001750 0001750 00000002753 12533641120 031026 0 ustar ben ben package com.baselet.element.elementnew.plot.elements;
import java.util.Arrays;
import java.util.List;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.element.elementnew.plot.drawer.PlotGridDrawConfig;
import com.baselet.element.elementnew.plot.parser.PlotConstants;
import com.baselet.element.elementnew.plot.parser.PlotConstants.AxisList;
import com.baselet.element.elementnew.plot.parser.PlotConstants.AxisShow;
import com.baselet.element.elementnew.plot.parser.PlotState;
public class ScatterPlot extends AbstractPlot {
public ScatterPlot(DrawHandler drawer, PlotGridDrawConfig plotDrawConfig, PlotState plotState, int xPos, int yPos) {
super(drawer, plotDrawConfig, plotState, xPos, yPos);
}
@Override
public void plot(int columnCount, int rowCount) {
setPlotPosition(columnCount, rowCount);
Boolean tilt = plotState.getValueAsBoolean(PlotConstants.KEY_BOOL_PLOT_TILT, PlotConstants.PLOT_TILT_DEFAULT);
plotState.checkIfAllValuesUsed();
plot.drawPlotAndDescValueAxis(!tilt, false, false, true);
}
@Override
protected List defaultDescAxisShow() {
return Arrays.asList(AxisShow.Axis, AxisShow.Marker, AxisShow.Text);
}
@Override
protected List defaultValueAxisShow() {
return defaultDescAxisShow();
}
@Override
protected List defaultValueAxisList() {
return Arrays.asList(AxisList.Relevant);
}
@Override
protected int getMaxAllowedValueRows() {
return Integer.MAX_VALUE;
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/drawer/ 0000755 0001750 0001750 00000000000 12533641120 027321 5 ustar ben ben ././@LongLink 0000644 0000000 0000000 00000000164 00000000000 011604 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/drawer/PlotGridDrawConfig.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/drawer/PlotGrid0000644 0001750 0001750 00000001340 12533641120 030766 0 ustar ben ben package com.baselet.element.elementnew.plot.drawer;
import com.baselet.control.basics.geom.Dimension;
public class PlotGridDrawConfig {
private final Dimension realSize;
private final Dimension size;
private final Double minValue;
private final Double maxValue;
public PlotGridDrawConfig(Dimension realSize, Dimension size, Double minValue, Double maxValue) {
super();
this.realSize = realSize;
this.size = size;
this.minValue = minValue;
this.maxValue = maxValue;
}
public Dimension getRealSize() {
return realSize;
}
public Dimension getSize() {
return size;
}
public Double getMinValue() {
return minValue;
}
public Double getMaxValue() {
return maxValue;
}
} ././@LongLink 0000644 0000000 0000000 00000000154 00000000000 011603 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/drawer/AxisConfig.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/drawer/AxisConf0000644 0001750 0001750 00000010720 12533641120 030756 0 ustar ben ben package com.baselet.element.elementnew.plot.drawer;
import java.util.List;
import java.util.TreeSet;
import com.baselet.element.elementnew.plot.parser.PlotConstants.AxisList;
import com.baselet.element.elementnew.plot.parser.PlotConstants.AxisShow;
public class AxisConfig {
private boolean descAxisLine, valueAxisLine;
private boolean descAxisMarkers, valueAxisMarkers;
private boolean descAxisText, valueAxisText;
private boolean descAxisGray, valueAxisGray;
private TreeSet valueAxisList;
private boolean showRelevantValues;
public static final int ARROW_SIZE = (int) (5 * 1f); // arrowLength * arrowEndAngle
public static final int ARROW_DISTANCE = ARROW_SIZE * 3; // Distance between outerBorder and innerBorder; plotarea where only axis are allowed to draw
private boolean xIsDescription;
private boolean drawAxis;
private int descSegment; // The width of a bar (always the "shorter" side of the bar)
private Double valueSegment; // How many pixels equal one valuesegment (eg: if values reach from 1 to 100000 it's very small, if they reach from 1 to 5 it's very high)
private int descAxisPos; // If horizontal sourceAxisPos is the x value of the vertical axis, else it's the y value of the horizontal axis
private int valueAxisPos; // If horizontal sourceAxisPos is the x value of the vertical axis, else it's the y value of the horizontal axis
private int xAxisPos;
private int yAxisPos;
public AxisConfig() {
super();
drawAxis = false;
}
public final void enableDescAxis(List showList/* , List valueList */) {
drawAxis = true;
descAxisLine = showList.contains(AxisShow.Axis.getValue());
descAxisGray = showList.contains(AxisShow.Line.getValue());
descAxisMarkers = showList.contains(AxisShow.Marker.getValue());
descAxisText = showList.contains(AxisShow.Text.getValue());
}
public final void enableValueAxis(List showList, List valueList) {
drawAxis = true;
valueAxisLine = showList.contains(AxisShow.Axis.getValue());
valueAxisGray = showList.contains(AxisShow.Line.getValue());
valueAxisMarkers = showList.contains(AxisShow.Marker.getValue());
valueAxisText = showList.contains(AxisShow.Text.getValue());
showRelevantValues = valueList.contains(AxisList.Relevant.getValue());
valueAxisList = new TreeSet();
for (String v : valueList) {
try {
valueAxisList.add(Double.parseDouble(v));
} catch (Exception e) {}
}
}
public boolean isxDescription() {
return xIsDescription;
}
public void setxIsDescription(boolean xIsDescription) {
this.xIsDescription = xIsDescription;
}
public boolean showAxis() {
return drawAxis;
}
public boolean drawXAxis() {
return isxDescription() && descAxisLine || !isxDescription() && valueAxisLine;
}
public boolean drawYAxis() {
return isxDescription() && valueAxisLine || !isxDescription() && descAxisLine;
}
public boolean drawDescriptionAxisMarkers() {
return descAxisMarkers;
}
public boolean drawDescriptionAxisMarkerText() {
return descAxisText;
}
public boolean drawDescriptionAxisMarkerGrayline() {
return descAxisGray;
}
public boolean drawValueAxis() {
return valueAxisLine;
}
public boolean drawValueAxisMarkers() {
return valueAxisMarkers;
}
public boolean drawValueAxisMarkerText() {
return valueAxisText;
}
public boolean drawValueAxisMarkerGrayline() {
return valueAxisGray;
}
public void setDescAxisPos(int pos) {
descAxisPos = pos;
if (xIsDescription) {
xAxisPos = pos;
}
else {
yAxisPos = pos;
}
}
public int getxAxisPos() {
return xAxisPos;
}
public void setValueAxisPos(int pos) {
valueAxisPos = pos;
if (!xIsDescription) {
xAxisPos = pos;
}
else {
yAxisPos = pos;
}
}
public int getyAxisPos() {
return yAxisPos;
}
public int getDescAxisPos() {
return descAxisPos;
}
public int getValueAxisPos() {
return valueAxisPos;
}
public int getDescSegment() {
return descSegment;
}
public void setDescSegment(int descSegment) {
this.descSegment = descSegment;
}
public Double getValueSegment() {
return valueSegment;
}
public void setValueSegment(Double valueSegment) {
this.valueSegment = valueSegment;
}
public TreeSet setValueAxisList(TreeSet valuesSorted) {
if (showRelevantValues) {
valueAxisList.addAll(valuesSorted);
}
return valueAxisList;
}
}
././@LongLink 0000644 0000000 0000000 00000000150 00000000000 011577 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/drawer/Canvas.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/drawer/Canvas.j0000644 0001750 0001750 00000011724 12533641120 030714 0 ustar ben ben package com.baselet.element.elementnew.plot.drawer;
import com.baselet.control.basics.geom.Dimension;
import com.baselet.control.basics.geom.Rectangle;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.diagram.draw.helper.ColorOwn;
import com.baselet.diagram.draw.helper.ColorOwn.Transparency;
/**
* GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
* G G
* G OOOOOOOOOOOOOOO G
* G O O G
* G O IIIIIIIII O G
* G O I I O G
* G O I I O G
* G O IIIIIIIII O G
* G O O G
* G OOOOOOOOOOOOOOO G
* G G
* G G
* G G
* G G
* G G
* G G
* GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
*/
public class Canvas {
private int borderspace;
private Rectangle outerBorder; // Nothing is drawn between outerBorder and the GridElement-Border
private Rectangle innerBorder; // Only axis are drawn between outerBorder and innerBorder; inside the innerBorder the plot is drawn
private Dimension gridElementSize;
public Canvas(Dimension gridElementSize) {
super();
this.gridElementSize = gridElementSize;
outerBorder = new Rectangle();
innerBorder = new Rectangle();
setBorder(0, 0, 0, 0, 0);
}
public void setBorder(int x, int y, int width, int height, int borderspace) {
this.borderspace = borderspace;
outerBorder.setBounds(x, y, width, height);
updateInnerBorder();
}
public void setBorderX(int x) {
outerBorder.setBounds(x, outerBorder.y, outerBorder.width, outerBorder.height);
updateInnerBorder();
}
public void setBorderY(int y) {
outerBorder.setBounds(outerBorder.x, y, outerBorder.width, outerBorder.height);
updateInnerBorder();
}
public void setBorderWidth(int width) {
outerBorder.setBounds(outerBorder.x, outerBorder.y, width, outerBorder.height);
updateInnerBorder();
}
public void setBorderHeight(int height) {
outerBorder.setBounds(outerBorder.x, outerBorder.y, outerBorder.width, height);
updateInnerBorder();
}
private void updateInnerBorder() {
innerBorder.setBounds(outerBorder.x + borderspace, outerBorder.y + borderspace, outerBorder.width + borderspace, outerBorder.height + borderspace);
}
/**
* <----->
* G O I I O G
*/
public int getInnerLeftPos() {
return innerBorder.x;
}
public int getInnerUpPos() {
return innerBorder.y;
}
/**
* <------------------>
* G O I I O G
*/
public int getInnerRightBorderWidth() {
return innerBorder.width;
}
public int getInnerDownBorderHeight() {
return innerBorder.height;
}
/**
* <------------->
* G O I I O G
*/
public int getInnerRightPos() {
return gridElementSize.width - getInnerRightBorderWidth();
}
public int getInnerDownPos() {
return gridElementSize.height - getInnerDownBorderHeight();
}
/**
* <-----> <------------------>
* G O I I O G
*/
public int getInnerHorizontalSum() {
return getInnerLeftPos() + getInnerRightBorderWidth();
}
public int getInnerVerticalSum() {
return getInnerUpPos() + getInnerDownBorderHeight();
}
/**
* <------->
* G O I I O G
*/
public int getInnerHorizontalDrawspace() {
return getInnerRightPos() - getInnerLeftPos();
}
public int getInnerVerticalDrawspace() {
return getInnerDownPos() - getInnerUpPos();
}
public int getOuterLeftPos() {
return outerBorder.x;
}
public int getOuterUpPos() {
return outerBorder.y;
}
public int getOuterRightBorderWidth() {
return outerBorder.width;
}
public int getOuterDownBorderHeight() {
return outerBorder.height;
}
public int getOuterRightPos() {
return gridElementSize.width - getOuterRightBorderWidth();
}
public int getOuterDownPos() {
return gridElementSize.height - getOuterDownBorderHeight();
}
public int getOuterHorizontalSum() {
return getOuterLeftPos() + getOuterRightBorderWidth();
}
public int getOuterVerticalSum() {
return getOuterUpPos() + getOuterDownBorderHeight();
}
public boolean hasHorizontalDrawspace() {
return gridElementSize.width > getOuterHorizontalSum();
}
public boolean hasVerticalDrawspace() {
return gridElementSize.width > getOuterHorizontalSum();
}
public void draw(DrawHandler baseDrawHandler) {
baseDrawHandler.setBackgroundColor(ColorOwn.TRANSPARENT);
baseDrawHandler.setForegroundColor(ColorOwn.RED.transparency(Transparency.BACKGROUND));
baseDrawHandler.drawRectangle(getOuterLeftPos(), getOuterUpPos(), getOuterRightPos() - getOuterLeftPos() - 1, getOuterDownPos() - getOuterUpPos());
baseDrawHandler.setForegroundColor(ColorOwn.BLUE);
baseDrawHandler.drawRectangle(getInnerLeftPos(), getInnerUpPos(), getInnerRightPos() - getInnerLeftPos(), getInnerDownPos() - getInnerUpPos());
}
}
././@LongLink 0000644 0000000 0000000 00000000161 00000000000 011601 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/drawer/PlotDrawHandler.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/drawer/PlotDraw0000644 0001750 0001750 00000056126 12533641120 031012 0 ustar ben ben package com.baselet.element.elementnew.plot.drawer;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeSet;
import com.baselet.control.SharedUtils;
import com.baselet.control.basics.geom.Dimension;
import com.baselet.control.basics.geom.Point;
import com.baselet.control.enums.AlignHorizontal;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.diagram.draw.helper.ColorOwn;
import com.baselet.diagram.draw.helper.ColorOwn.Transparency;
public class PlotDrawHandler {
// Enumerations
public enum Position {
LEFT, UP, DOWN, RIGHT
}
// Plot specific settings
private String[] title;
private String[] desc;
private Double[][] values;
private TreeSet valuesSorted;
private TreeSet valuesShownOnAxisSorted;
// private Double[][] valuesMinMaxCorrected; // if all values are >0 or all values are <0 the distance from 0 to the first real value will be subtracted
protected DrawHandler base;
private Double minVal = null;
private Double maxVal = null;
private List colors;
private final Canvas canvas;
private final AxisConfig axisConfig;
public PlotDrawHandler(DrawHandler baseDrawHandler, Dimension size) {
base = baseDrawHandler;
// drawLegend = false;
axisConfig = new AxisConfig();
canvas = new Canvas(size);
}
// Legend Settings
// private boolean drawLegend;
// private Rectangle legendPos;
// /**
// * Abstracts the axis drawing from the type of variables on the axis (description or values)
// * Methods called from this method don't know if they handle a description or value axis
// * @param xAxis if true this is the method call for the x-axis
// * @param valuesSorted the sorted list of values
// */
// private void abstractValueDescFromAxisAndDraw(boolean xAxis) {
// int segmentDisp, lastDrawnSegmentDisp;
//
// if /* thisIsDescAxis */ ((xAxis && axisConfig.isxDescription()) || (!xAxis && !axisConfig.isxDescription())) {
// // if (axisConfig.drawDescriptionAxis()) drawAxisLine(xAxis);
// if (true) {
// lastDrawnSegmentDisp = -axisConfig.getDescSegment()/2;
// for (int i = 0; i < desc.length; i++) {
// segmentDisp = (i * axisConfig.getDescSegment()) + (axisConfig.getDescSegment()/2);
// String value;
// if (xAxis) value = desc[i];
// else value = desc[desc.length-i-1]; // yAxis is drawn from bottom to top, therefore invert computation direction
// // axisConfig.activateDescriptionAxis();
// lastDrawnSegmentDisp = drawMarkerTextIfThereIsEnoughSpace(xAxis, segmentDisp, lastDrawnSegmentDisp, value);
// }
// }
// }
// else /* thisIsValueAxis */ {
// // if (axisConfig.drawValueAxis()) drawAxisLine(xAxis);
// if (true) {
// Double[] valuesToDisplay;
// if (axisConfig.drawValueAxisMarkersAll()) {
// if (axisConfig.getValueSegment() < 1) valuesToDisplay = Utils.createDoubleArrayFromTo(minVal, maxVal, Math.ceil(1/axisConfig.getValueSegment()));
// else valuesToDisplay = Utils.createDoubleArrayFromTo(minVal, maxVal);
// }
// else valuesToDisplay = valuesSorted;
//
// lastDrawnSegmentDisp = (int) (valuesToDisplay[0] * axisConfig.getValueSegment() - 100); // Start at the lowest possible number
// for (Double v : valuesToDisplay) {
// segmentDisp = (int) calculateValuePos(v, axisConfig.getValueSegment());
// // valueStringToDisplay is the String representation of the value (".0" should not be displayed)
// String valueStringToDisplay = (Math.round(v) == v) ? String.valueOf(Math.round(v)) : String.valueOf(v);
// if (axisConfig.drawValueAxisMarkersAll()) {
// int oldLength = valueStringToDisplay.length();
// if (oldLength > 2) {
// valueStringToDisplay = valueStringToDisplay.substring(0, 2);
// for (int i = 0; i < oldLength-2; i++) valueStringToDisplay += "0";
// }
// }
// // if (value == 0) continue; // 0 is not displayed because it would overlap with the arrow end
// // axisConfig.activateValueAxis();
// lastDrawnSegmentDisp = drawMarkerTextIfThereIsEnoughSpace(xAxis, segmentDisp, lastDrawnSegmentDisp, valueStringToDisplay);
// }
// }
// }
// }
//
// /**
// * Draws text descriptions of axes only if there is enough space for it.
// */
// private int drawMarkerTextIfThereIsEnoughSpace(boolean xAxis, int segmentDisp, int lastDrawnSegmentDisp, String valueAsString) {
// boolean drawMarker = false;
// // If text should be displayed markers where there would be no space for the text are not drawn
// // if (axisConfig.drawActiveAxisMarkerText()) {
// int textSpaceNeeded;
// if (xAxis) textSpaceNeeded = base.textWidth(valueAsString);
// else textSpaceNeeded = base.textHeight();
// if ((segmentDisp - lastDrawnSegmentDisp) >= textSpaceNeeded) {
// drawMarker = true;
// lastDrawnSegmentDisp = segmentDisp;
// }
// // }
// else drawMarker = true;
//
// if (drawMarker) drawAxisMarker(xAxis, segmentDisp, valueAsString);
// return lastDrawnSegmentDisp;
// }
// //TODO isnt working properly now
// public void enableLegend(Position position) {
// this.drawLegend = true;
// this.legendPos = getLegendPosition(position);
// }
//
// public void disableLegend() {
// this.drawLegend = false;
// }
//
// private void drawLegend() {
// base.drawRectangle(legendPos.x, legendPos.y, legendPos.width, legendPos.height);
// }
//
// private Rectangle getLegendPosition(Position position) {
// // Calculate size of the legend
// final Rectangle innerLegendBorder = new Rectangle(10, 10, 10, 10);
// int legendWidth = innerLegendBorder.x + innerLegendBorder.width;
// int legendHeight = innerLegendBorder.y + innerLegendBorder.height;
// final int legendSpace = 10;
//
// int textWidth;
// for (String v : desc) {
// legendHeight += base.textHeight();
// textWidth = base.textWidth(v) + innerLegendBorder.x + innerLegendBorder.width;
// if (textWidth > legendWidth) legendWidth = textWidth;
// }
//
// // The outerBorder of the plot must be adjusted to free space for the legend
// int borderX = canvas.getOuterLeftPos();
// int borderY = canvas.getOuterUpPos();
// int borderW = canvas.getOuterRightBorderWidth();
// int borderH = canvas.getOuterDownBorderHeight();
//
// if (position == Position.LEFT) borderX += legendWidth + legendSpace;
// else if (position == Position.RIGHT) borderW += legendWidth + legendSpace;
// else if (position == Position.UP) borderY += legendHeight + legendSpace;
// else if (position == Position.DOWN) borderH += legendHeight + legendSpace;
//
// canvas.setBorder(borderX, borderY, borderW, borderH, AxisConfig.ARROW_DISTANCE);
//
// // Calculate and return the position of the legend rectangle
// final int x, y;
// if (position == Position.LEFT || position == Position.RIGHT) {
// y = (canvas.getInnerDownPos() - legendHeight) / 2;
// if (position == Position.LEFT) {
// x = 1;
// } else {
// x = canvas.getInnerRightPos() - legendWidth - legendSpace/2;
// }
// } else {
// x = (canvas.getInnerRightPos() - legendWidth) / 2;
// if (position == Position.UP) {
// y = 1;
// } else {
// y = canvas.getInnerDownPos() - legendHeight - legendSpace/2;
// }
// }
// return new Rectangle(x, y, legendWidth, legendHeight);
// }
public final void drawPlotAndDescValueAxis(boolean xIsDescription, boolean drawBars, boolean drawLines, boolean drawPoints) {
axisConfig.setxIsDescription(xIsDescription);
setupAxis();
calculateAdditionalSpaceForYAxisTextWidth();
// log.debug("yIsDescription: " + yIsDescription + ", descSegment: " + axisConfig.getDescSegment() + ", valueSegment: " + axisConfig.getValueSegment());
// log.debug("valueRange: " + valueRange + ", barsCount: " + elementCount + ", SourceAxisPos/DescAxisPos: " + axisConfig.getDescAxisPos() + ", BarStart/ValueAxisPos: " + axisConfig.getValueAxisPos());
if (drawBars) {
drawBars(xIsDescription, values, axisConfig.getDescAxisPos(), axisConfig.getValueAxisPos(), axisConfig.getValueSegment(), axisConfig.getDescSegment(), colors);
}
if (drawLines) {
drawLineOrPoints(xIsDescription, values, axisConfig.getDescAxisPos(), axisConfig.getValueAxisPos(), axisConfig.getValueSegment(), axisConfig.getDescSegment(), colors, true);
}
if (drawPoints) {
drawLineOrPoints(xIsDescription, values, axisConfig.getDescAxisPos(), axisConfig.getValueAxisPos(), axisConfig.getValueSegment(), axisConfig.getDescSegment(), colors, false);
}
if (axisConfig.showAxis()) {
drawAxis(xIsDescription, axisConfig.getDescAxisPos(), axisConfig.getValueAxisPos(), axisConfig.getValueSegment(), axisConfig.getDescSegment());
}
}
private void setupAxis() {
final Double valueRange = Math.max(1.0, maxVal - minVal); // The range is >=1 (otherwise nothing will be drawn)
Double negativeRange = 0.0;
if (minVal > 0) {
negativeRange = 0.0;
}
if (minVal < 0) {
if (maxVal < 0) {
negativeRange = valueRange;
}
else {
negativeRange = -minVal;
}
}
int elementCount = desc.length; // Amount of bars/lines/...
for (Double[] vArray : values) {
if (vArray.length > elementCount) {
elementCount = vArray.length;
}
}
// Calculate some necessary variables to draw the bars (these variables abstract from horizontal/vertical to a relative point of view)
if (axisConfig.isxDescription()) {
axisConfig.setDescSegment(canvas.getInnerHorizontalDrawspace() / elementCount);
axisConfig.setValueSegment(canvas.getInnerVerticalDrawspace() / valueRange);
axisConfig.setDescAxisPos((int) (canvas.getInnerDownPos() - axisConfig.getValueSegment() * negativeRange));
axisConfig.setValueAxisPos(canvas.getInnerLeftPos());
}
else {
axisConfig.setDescSegment(canvas.getInnerVerticalDrawspace() / elementCount);
axisConfig.setValueSegment(canvas.getInnerHorizontalDrawspace() / valueRange);
axisConfig.setDescAxisPos((int) (canvas.getInnerLeftPos() + axisConfig.getValueSegment() * negativeRange));
axisConfig.setValueAxisPos(canvas.getInnerUpPos());
}
}
private final void drawAxis(boolean xIsDescription, int sourceAxisPos, int valueAxisPos, Double valueSegment, int descSegment) {
List xpoints = new ArrayList();
List xtext = new ArrayList();
List ypoints = new ArrayList();
List ytext = new ArrayList();
int lineIterator = valueAxisPos + descSegment / 2;
for (String d : desc) {
if (xIsDescription) {
xpoints.add(lineIterator);
xtext.add(d);
}
else {
ypoints.add(lineIterator);
ytext.add(d);
}
lineIterator += descSegment;
}
for (Double v : valuesShownOnAxisSorted) {
int linePos = (int) calculateValuePos(v, valueSegment);
if (xIsDescription) {
ypoints.add(sourceAxisPos - linePos);
ytext.add(String.valueOf(v));
}
else {
xpoints.add(sourceAxisPos + linePos);
xtext.add(String.valueOf(v));
}
}
drawGraylines(xpoints, ypoints);
base.setForegroundColor(ColorOwn.BLACK.transparency(Transparency.FOREGROUND));
drawAxisLine();
drawMarkers(xpoints, ypoints);
drawMarkerTexts(xpoints, xtext, ypoints, ytext);
}
/**
* Method to draw one line (which one is specified by the boolean xAxis variable)
* @param xAxis
* @param drawArrows
*/
private void drawAxisLine() {
if (axisConfig.drawXAxis()) {
final int x1 = canvas.getInnerLeftPos();
final int x2 = canvas.getInnerRightPos();
final int y = axisConfig.getxAxisPos();
base.drawLine(x1, y, x2, y);
}
if (axisConfig.drawYAxis()) {
final int x = axisConfig.getyAxisPos();
final int y1 = canvas.getInnerUpPos();
final int y2 = canvas.getInnerDownPos();
base.drawLine(x, y1, x, y2);
}
}
private void drawGraylines(List xpoints, List ypoints) {
base.setForegroundColor(ColorOwn.BLACK.transparency(Transparency.SELECTION_BACKGROUND));
boolean drawVerticalGraylines = axisConfig.isxDescription() && axisConfig.drawDescriptionAxisMarkerGrayline() || !axisConfig.isxDescription() && axisConfig.drawValueAxisMarkerGrayline();
boolean drawHorizontalGraylines = !axisConfig.isxDescription() && axisConfig.drawDescriptionAxisMarkerGrayline() || axisConfig.isxDescription() && axisConfig.drawValueAxisMarkerGrayline();
if (drawVerticalGraylines) {
for (Integer x : xpoints) {
base.drawLine(x, canvas.getInnerUpPos(), x, canvas.getInnerDownPos());
}
}
if (drawHorizontalGraylines) {
for (Integer y : ypoints) {
base.drawLine(canvas.getInnerLeftPos(), y, canvas.getInnerRightPos(), y);
}
}
}
private void drawMarkers(List xpoints, List ypoints) {
boolean drawVerticalMarkers = axisConfig.isxDescription() && axisConfig.drawDescriptionAxisMarkers() || !axisConfig.isxDescription() && axisConfig.drawValueAxisMarkers();
boolean drawHorizontalMarkers = !axisConfig.isxDescription() && axisConfig.drawDescriptionAxisMarkers() || axisConfig.isxDescription() && axisConfig.drawValueAxisMarkers();
if (drawVerticalMarkers) {
for (Integer x : xpoints) {
base.drawLine(x, axisConfig.getxAxisPos(), x, axisConfig.getxAxisPos() + AxisConfig.ARROW_SIZE);
}
}
if (drawHorizontalMarkers) {
for (Integer y : ypoints) {
base.drawLine(axisConfig.getyAxisPos() - AxisConfig.ARROW_SIZE, y, axisConfig.getyAxisPos(), y);
}
}
}
private void drawMarkerTexts(List xpoints, List xtext, List ypoints, List ytext) {
boolean drawVerticalMarkerTexts = axisConfig.isxDescription() && axisConfig.drawDescriptionAxisMarkerText() || !axisConfig.isxDescription() && axisConfig.drawValueAxisMarkerText();
boolean drawHorizontalMarkerTexts = !axisConfig.isxDescription() && axisConfig.drawDescriptionAxisMarkerText() || axisConfig.isxDescription() && axisConfig.drawValueAxisMarkerText();
if (drawVerticalMarkerTexts) {
for (int i = 0; i < xpoints.size(); i++) {
base.print(xtext.get(i), xpoints.get(i), axisConfig.getxAxisPos() + AxisConfig.ARROW_DISTANCE, AlignHorizontal.CENTER);
}
}
if (drawHorizontalMarkerTexts) {
for (int i = 0; i < ypoints.size(); i++) {
base.print(ytext.get(i), axisConfig.getyAxisPos() - 8, (int) (ypoints.get(i) + base.textHeightMax() / 2), AlignHorizontal.RIGHT);
}
}
}
private final void drawLineOrPoints(boolean xIsDescription, Double[][] values, int sourceAxisPos, int valueAxisPos, Double valueSegment, int descSegment, List colors, boolean line) {
int cIndex = 0;
for (int valueIndex = 0; valueIndex < values.length; valueIndex++) {
Double[] vArray = values[valueIndex];
int actualValPos;
int lineIterator = valueAxisPos + descSegment / 2;
List points = new ArrayList();
for (Double v : vArray) {
actualValPos = (int) calculateValuePos(v, valueSegment);
if (xIsDescription) {
points.add(new Point(lineIterator, sourceAxisPos - actualValPos));
}
else {
points.add(new Point(sourceAxisPos + actualValPos, lineIterator));
}
lineIterator += descSegment;
}
if (cIndex >= colors.size())
{
cIndex = 0; // Restart with first color if all colors in the array has been used
}
base.setForegroundColor(ColorOwn.forStringOrNull(colors.get(cIndex), Transparency.FOREGROUND));
base.setBackgroundColor(ColorOwn.forStringOrNull(colors.get(cIndex), Transparency.FOREGROUND));
if (line) {
for (int i = 0; i < points.size() - 1; i++) {
Point point1 = points.get(i);
Point point2 = points.get(i + 1);
base.drawLine(point1.x, point1.y, point2.x, point2.y);
}
}
else {
for (int i = 0; i < points.size(); i++) {
Point point = points.get(i);
base.drawCircle(point.x, point.y, 2);
}
}
// print titleCol
base.setForegroundColor(ColorOwn.forStringOrNull(colors.get(cIndex), Transparency.FOREGROUND).darken(75));
base.print(title[valueIndex], points.get(points.size() - 1).x, points.get(points.size() - 1).y, AlignHorizontal.CENTER);
cIndex++;
}
base.resetColorSettings();
}
private final void drawBars(boolean xIsDescription, Double[][] values, int sourceAxisPos, int valueAxisPos, Double valueSegment, int descSegment, List colors) {
int barLength;
int valueRowAmount = values.length;
for (int vIndex = 0; vIndex < valueRowAmount; vIndex++) {
int cIndex = 0;
int subBarIterator = valueAxisPos;
for (Double v : values[vIndex]) {
if (cIndex >= colors.size())
{
cIndex = 0; // Restart with first color if all colors in the array has been used
}
base.setForegroundColor(ColorOwn.TRANSPARENT);
base.setBackgroundColor(colors.get(cIndex));
barLength = (int) calculateValuePos(v, valueSegment);
int barWidth = 0;
int ownvar = vIndex * (int) Math.round((double) descSegment / valueRowAmount);
// calculate last bar width, fixing rounding errors
if (vIndex == valueRowAmount - 1) {
barWidth = subBarIterator + descSegment - (subBarIterator + ownvar);
}
else {
barWidth = (int) Math.round((double) descSegment / valueRowAmount);
}
if (xIsDescription) {
if (barLength > 0) {
base.drawRectangle(subBarIterator + ownvar, sourceAxisPos - barLength, barWidth, barLength);
}
else {
base.drawRectangle(subBarIterator + ownvar, sourceAxisPos, barWidth, -barLength);
}
}
else {
if (barLength > 0) {
base.drawRectangle(sourceAxisPos, subBarIterator + ownvar, barLength, barWidth);
}
else {
base.drawRectangle(sourceAxisPos + barLength, subBarIterator + ownvar, -barLength, barWidth);
}
}
subBarIterator += descSegment;
cIndex++;
}
}
base.resetColorSettings();
}
public final void drawPiePlot() {
Double valueSum = 0.0;
for (Double v : values[0]) {
valueSum += Math.abs(v);
}
final Point ulCorner;
final int diameter;
int height = canvas.getInnerVerticalDrawspace();
int width = canvas.getInnerHorizontalDrawspace();
diameter = height > width ? width : height;
ulCorner = new Point(canvas.getInnerLeftPos(), canvas.getInnerUpPos());
drawPieArcs(values[0], desc, ulCorner, diameter, valueSum, colors);
}
private final void drawPieArcs(Double[] values, String[] desc, Point ulCorner, int diameter, Double valueSum, List colors) {
int cIndex = 0;
Double arcAngle = 0D;
Double startAngle = 0D;
for (int i = 0; i < values.length; i++) {
if (cIndex >= colors.size())
{
cIndex = 0; // Restart with first color if all colors in the array has been used
}
ColorOwn currentFg = base.getForegroundColor();
base.setForegroundColor(ColorOwn.TRANSPARENT);
base.setBackgroundColor(colors.get(cIndex));
arcAngle = i < values.length - 1 ? Math.round(360.0 / valueSum * Math.abs(values[i])) : 360 - startAngle;
// System.out.println("val: "+values[i]+" winkel: "+arcAngle);
int height = canvas.getInnerVerticalDrawspace();
int width = canvas.getInnerHorizontalDrawspace();
base.drawArc(ulCorner.x + width / 2.0 - diameter / 2.0, ulCorner.y + height / 2.0 - diameter / 2.0, diameter, diameter, startAngle.floatValue(), arcAngle.floatValue(), false);
base.setForegroundColor(currentFg);
double radians = (360 - startAngle + (360 - arcAngle / 2)) * Math.PI / 180.0;
int value_x = (int) (diameter / 2.0 * Math.cos(radians) + ulCorner.x + diameter / 2.0 + width / 2.0 - diameter / 2.0);
int value_y = (int) (diameter / 2.0 * Math.sin(radians) + ulCorner.y + diameter / 2.0 + height / 2.0 - diameter / 2.0);
base.setForegroundColor(ColorOwn.forStringOrNull(colors.get(cIndex), Transparency.FOREGROUND).darken(75));
base.print(desc[i], value_x, value_y, AlignHorizontal.CENTER);
// System.out.println("value_x: "+value_x+" / value_y:"+value_y);
startAngle += arcAngle;
cIndex++;
}
base.resetColorSettings();
}
private void calculateAdditionalSpaceForYAxisTextWidth() {
double maxWidth = 0;
double valueWidth;
if (axisConfig.isxDescription()) { // y-axis contains values
if (axisConfig.drawValueAxisMarkerText()) {
for (Double v : valuesShownOnAxisSorted) {
valueWidth = base.textWidth(String.valueOf(v));
if (valueWidth > maxWidth) {
maxWidth = valueWidth;
}
}
}
}
else { // y-axis contains description
if (axisConfig.drawDescriptionAxisMarkerText()) {
for (String d : desc) {
valueWidth = base.textWidth(d);
if (valueWidth > maxWidth) {
maxWidth = valueWidth;
}
}
}
}
double adjustValue = maxWidth + canvas.getOuterLeftPos() - (axisConfig.getyAxisPos() - canvas.getInnerLeftPos()) - 5;
if (adjustValue > canvas.getOuterLeftPos()) {
canvas.setBorderX((int) adjustValue);
setupAxis();
// If the y-axis is not exactly over the innerleft-border, it will be displaced by the last setupAxis() call and therefore the additional space for it must be recalculated again
if (axisConfig.getyAxisPos() - canvas.getInnerLeftPos() != 0) {
adjustValue = maxWidth + canvas.getOuterLeftPos() - (axisConfig.getyAxisPos() - canvas.getInnerLeftPos()) - 5;
if (adjustValue > canvas.getOuterLeftPos()) {
canvas.setBorderX((int) adjustValue);
setupAxis();
}
}
}
}
/**
* Calculated value * valueSegment but account for displacements of values if all values are positive or negativ (= positive minVal or negative maxVal)
*/
public double calculateValuePos(double value, double valueSegment) {
if (value > 0 && minVal > 0) {
value -= minVal;
}
else if (value < 0 && maxVal < 0) {
value -= maxVal;
}
return value * valueSegment;
}
public void setValues(String[] desc, String[] title, Double[][] values, List colors) {
this.desc = SharedUtils.cloneArray(desc);
this.title = SharedUtils.cloneArray(title);
this.colors = new ArrayList(colors);
this.values = SharedUtils.cloneArray(values);
valuesSorted = new TreeSet();
for (Double[] vArray : values) {
for (Double v : vArray) {
valuesSorted.add(v);
}
}
valuesShownOnAxisSorted = axisConfig.setValueAxisList(valuesSorted);
minVal = minRealOrShownValue();
maxVal = maxRealOrShownValue();
}
public void setMinValue(Double minVal) throws IOException {
Double limit = Math.min(minRealOrShownValue(), maxVal);
if (minVal > limit) {
throw new IOException("minValue must be <= " + limit);
}
else {
this.minVal = minVal;
}
}
public void setMaxValue(Double maxVal) throws IOException {
Double limit = Math.max(maxRealOrShownValue(), minVal);
if (maxVal < limit) {
throw new IOException("maxValue must be >= " + limit);
}
else {
this.maxVal = maxVal;
}
}
private double minRealOrShownValue() {
if (valuesShownOnAxisSorted.isEmpty()) {
return valuesSorted.first();
}
else {
return Math.min(valuesSorted.first(), valuesShownOnAxisSorted.first());
}
}
private double maxRealOrShownValue() {
if (valuesShownOnAxisSorted.isEmpty()) {
return valuesSorted.last();
}
else {
return Math.max(valuesSorted.last(), valuesShownOnAxisSorted.last());
}
}
public Canvas getCanvas() {
return canvas;
}
public AxisConfig getAxisConfig() {
return axisConfig;
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/plot/PlotGrid.java 0000644 0001750 0001750 00000026104 12533641120 030427 0 ustar ben ben package com.baselet.element.elementnew.plot;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import com.baselet.control.Matrix;
import com.baselet.control.basics.geom.Dimension;
import com.baselet.control.enums.AlignHorizontal;
import com.baselet.control.enums.ElementId;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.diagram.draw.helper.ColorOwn;
import com.baselet.element.NewGridElement;
import com.baselet.element.elementnew.plot.drawer.PlotGridDrawConfig;
import com.baselet.element.elementnew.plot.elements.AbstractPlot;
import com.baselet.element.elementnew.plot.elements.BarPlot;
import com.baselet.element.elementnew.plot.elements.LinePlot;
import com.baselet.element.elementnew.plot.elements.PiePlot;
import com.baselet.element.elementnew.plot.elements.ScatterPlot;
import com.baselet.element.elementnew.plot.parser.Parser;
import com.baselet.element.elementnew.plot.parser.ParserException;
import com.baselet.element.elementnew.plot.parser.ParserResult;
import com.baselet.element.elementnew.plot.parser.PlotConstants;
import com.baselet.element.elementnew.plot.parser.PlotConstants.PlotType;
import com.baselet.element.elementnew.plot.parser.PlotState;
import com.baselet.element.facet.Facet;
import com.baselet.element.facet.PropertiesParserState;
import com.baselet.element.facet.Settings;
import com.baselet.element.settings.SettingsManualresizeCenter;
import com.baselet.gui.AutocompletionText;
public class PlotGrid extends NewGridElement {
private static final Logger log = Logger.getLogger(PlotGrid.class);
private Matrix> matrix;
private Integer gridWidth;
private Double minValue;
private Double maxValue;
/**
* this facet is only here to show autocompletion and include PlotGrid in the new parser logic which uses facets
*/
public static final Facet PSEUDO_PLOT_FACET = new Facet() {
@Override
public void handleLine(String line, PropertiesParserState propConfig) {
// do nothing
}
@Override
public List getAutocompletionStrings() {
return PlotConstants.AUTOCOMPLETION_LIST;
}
@Override
public boolean checkStart(String line, PropertiesParserState propConfig) {
return true;
}
};
private void fillWithPlots(ParserResult parserState) {
ArrayList plotStateList = parserState.getPlotStateList();
DrawHandler drawer = parserState.getDrawer();
setOverallMinMaxValue(plotStateList);
for (PlotState plotState : plotStateList) {
Integer xPos = plotState.getValueAsInt(PlotConstants.KEY_INT_X_POSITION, null);
Integer yPos = plotState.getValueAsInt(PlotConstants.KEY_INT_Y_POSITION, null);
// 1 is subtracted from the values because the user counts from 1 to x; java counts from 0 to x-1
if (xPos != null) {
xPos -= 1;
}
if (yPos != null) {
yPos -= 1;
}
// case1: x and y are specified
if (xPos != null && yPos != null) {
setMatrixHeightMinimum(yPos);
List> xCoordinateList = matrix.row(yPos);
setMinimumListSize(xPos, xCoordinateList);
xCoordinateList.set(xPos, createPlots(drawer, plotState, xPos, yPos, "x and y are specified"));
}
// case2: only x is specified
else if (xPos != null) {
putPlotInFirstFreeVerticalSpaceOrAddPlot(drawer, xPos, plotState, "only x is specified -> space replaced");
}
// case3: only y is specified
else if (yPos != null) {
setMatrixHeightMinimum(yPos);
List> xCoordinateList = matrix.row(yPos);
putPlotInFirstFreeHorizontalSpaceOrAddPlot(drawer, xCoordinateList, yPos, plotState, "only y specified -> ");
}
// case4: no coordinate is specified
else {
putPlotInFirstFreeMatrixSpace(drawer, plotState);
}
}
gridWidth = matrix.cols(); // Recalculate grid width
log.debug("\n" + toString() + "\n");
}
private void setOverallMinMaxValue(List plotStateList) {
minValue = Double.MAX_VALUE;
maxValue = Double.MIN_VALUE;
Double[][] data;
for (PlotState state : plotStateList) {
data = state.getDataSet().data();
for (Double[] dArray : data) {
for (Double d : dArray) {
if (d > maxValue) {
maxValue = d;
}
if (d < minValue) {
minValue = d;
}
}
}
}
}
private void setMatrixHeightMinimum(Integer minHeight) {
while (minHeight > matrix.rows() - 1) {
matrix.addLine(new ArrayList>());
}
}
private void setMinimumListSize(Integer minWidth, List> lineToSet) {
while (minWidth > lineToSet.size() - 1) {
lineToSet.add(null);
}
}
private void putPlotInFirstFreeVerticalSpaceOrAddPlot(DrawHandler drawer, Integer xFix, PlotState plotState, String info) {
boolean plotFilledInFreeSpace = false;
for (int ySeq = 0; ySeq < matrix.rows(); ySeq++) {
List> xCoordinateList = matrix.row(ySeq);
if (xFix >= xCoordinateList.size()) {
setMinimumListSize(xFix, xCoordinateList);
}
if (xCoordinateList.get(xFix) == null) {
xCoordinateList.set(xFix, createPlots(drawer, plotState, xFix, ySeq, info));
plotFilledInFreeSpace = true;
break;
}
}
// If there is no free space available for the plot, a new line must be added
if (!plotFilledInFreeSpace) {
ArrayList> newColumn = new ArrayList>();
setMinimumListSize(xFix, newColumn);
newColumn.set(xFix, createPlots(drawer, plotState, xFix, matrix.rows(), "only x is specified -> expanded y-list"));
matrix.addLine(newColumn);
}
}
private void putPlotInFirstFreeHorizontalSpaceOrAddPlot(DrawHandler drawer, List> xCoordinateList, Integer yFix, PlotState plotState, String info) {
for (int xSeq = 0; true; xSeq++) {
if (xSeq == xCoordinateList.size()) {
xCoordinateList.add(createPlots(drawer, plotState, xSeq, yFix, info + "added new x-entry"));
return;
}
if (xCoordinateList.get(xSeq) == null) {
xCoordinateList.set(xSeq, createPlots(drawer, plotState, xSeq, yFix, info + "replaced x-entry"));
return;
}
}
}
private void putPlotInFirstFreeMatrixSpace(DrawHandler drawer, PlotState plotState) {
// Go through all lines and all values in each line
for (int ySeq = 0; ySeq < matrix.rows(); ySeq++) {
List> oneLine = matrix.row(ySeq);
for (int xSeq = 0; xSeq < oneLine.size(); xSeq++) {
List oneValue = oneLine.get(xSeq);
// If a free space is found use it
if (oneValue == null) {
oneLine.set(xSeq, createPlots(drawer, plotState, xSeq, ySeq, "no coordinate specified -> free space found"));
return;
}
}
// If the actual x-coordinates line is < than the default grid width add a new value
if (oneLine.size() < gridWidth) {
oneLine.add(createPlots(drawer, plotState, oneLine.size(), ySeq, "no coordinate specified -> expanded x-list"));
return;
}
}
// If every space in the matrix is occupied and the position is still not found add a new line and fill its first place
List> newLine = new ArrayList>();
newLine.add(createPlots(drawer, plotState, 0, matrix.rows(), "no coordinate specified -> every matrix space occupied, expanded y-list"));
matrix.addLine(newLine);
}
private List createPlots(DrawHandler drawer, PlotState plotState, Integer xPos, Integer yPos, String info)
{
List plotList = new ArrayList();
// create and add base plot
plotList.add(createPlot(drawer, plotState, xPos, yPos, info));
// create and add sub plots
for (PlotState subPlotState : plotState.getSubplots()) {
plotList.add(createPlot(drawer, subPlotState, xPos, yPos, info));
}
return plotList;
}
private AbstractPlot createPlot(DrawHandler drawer, PlotState plotState, int xPos, int yPos, String info) {
String type = plotState.getValueValidated(PlotType.getKey(), PlotType.Bar.getValue(), PlotConstants.toStringList(PlotType.values()));
log.debug("PlotGrid insert : " + type + " (" + xPos + ";" + yPos + ") " + info);
PlotGridDrawConfig plotDrawConfig = new PlotGridDrawConfig(getRealSize(), new Dimension(getRectangle().width, getRectangle().height), minValue, maxValue);
if (PlotType.Pie.getValue().equals(type)) {
return new PiePlot(drawer, plotDrawConfig, plotState, xPos, yPos);
}
else if (PlotType.Line.getValue().equals(type)) {
return new LinePlot(drawer, plotDrawConfig, plotState, xPos, yPos);
}
else if (PlotType.Scatter.getValue().equals(type)) {
return new ScatterPlot(drawer, plotDrawConfig, plotState, xPos, yPos);
}
else {
return new BarPlot(drawer, plotDrawConfig, plotState, xPos, yPos);
}
}
public void drawPlots() {
for (int row = 0; row < matrix.rows(); row++) {
for (int col = 0; col < matrix.row(row).size(); col++) {
List oneCell = matrix.cell(row, col);
for (AbstractPlot onePlot : oneCell)
{
if (onePlot != null) {
if (col != onePlot.getXPosition()) {
log.error("Plot contains wrong coordinates: " + col + " != " + onePlot.getXPosition());
}
if (row != onePlot.getYPosition()) {
log.error("Plot contains wrong coordinates: " + row + " != " + onePlot.getYPosition());
}
onePlot.plot(matrix.cols(), matrix.rows());
}
}
}
}
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("------------------------------\n");
for (int i = 0; i < matrix.rows(); i++) {
List> row = matrix.row(i);
for (List oneCell : row)
{
for (AbstractPlot onePlot : oneCell) {
if (onePlot == null) {
sb.append("null\t");
}
else {
sb.append(onePlot.getPlotLineNr()).append("\t");
}
}
}
sb.append("\n");
}
return sb.append("------------------------------").toString();
}
@Override
protected void drawCommonContent(PropertiesParserState state) {
DrawHandler drawer = state.getDrawer();
try {
matrix = new Matrix>();
ParserResult parserState = new Parser().parse(getPanelAttributes());
parserState.setDrawer(drawer);
log.debug(parserState.toString());
gridWidth = Integer.parseInt(parserState.getPlotGridValue(PlotConstants.KEY_INT_GRID_WIDTH, PlotConstants.GRID_WIDTH_DEFAULT));
fillWithPlots(parserState);
drawPlots();
} catch (ParserException e) {
drawer.setForegroundColor(ColorOwn.RED);
drawer.setBackgroundColor(ColorOwn.WHITE);
drawer.drawRectangle(0, 0, getRectangle().width - 1, getRectangle().height - 1);
float x = getRectangle().getWidth() / 2.0f;
drawer.print(e.getMessage(), x, getRealSize().height / 2.0, AlignHorizontal.CENTER);
}
}
@Override
protected Settings createSettings() {
return new SettingsManualresizeCenter() {
@Override
protected List createFacets() {
return listOf(PSEUDO_PLOT_FACET); // no real facets should be used
}
};
}
@Override
public ElementId getId() {
return ElementId.PlotGrid;
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/uml/ 0000755 0001750 0001750 00000000000 12533641120 025654 5 ustar ben ben ././@LongLink 0000644 0000000 0000000 00000000146 00000000000 011604 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/uml/SpecialState.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/uml/SpecialState.jav0000644 0001750 0001750 00000001557 12533641120 030747 0 ustar ben ben package com.baselet.element.elementnew.uml;
import java.util.List;
import com.baselet.control.enums.ElementId;
import com.baselet.element.NewGridElement;
import com.baselet.element.facet.Facet;
import com.baselet.element.facet.PropertiesParserState;
import com.baselet.element.facet.Settings;
import com.baselet.element.facet.specific.SpecialStateTypeFacet;
import com.baselet.element.settings.SettingsNoText;
public class SpecialState extends NewGridElement {
@Override
public ElementId getId() {
return ElementId.UMLSpecialState;
}
@Override
protected void drawCommonContent(PropertiesParserState state) {}
@Override
protected Settings createSettings() {
return new SettingsNoText() {
@Override
protected List createFacets() {
return listOf(super.createFacets(), SpecialStateTypeFacet.INSTANCE);
}
};
}
}
././@LongLink 0000644 0000000 0000000 00000000150 00000000000 011577 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/uml/ActivityObject.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/uml/ActivityObject.j0000644 0001750 0001750 00000001735 12533641120 030760 0 ustar ben ben package com.baselet.element.elementnew.uml;
import java.util.List;
import com.baselet.control.enums.ElementId;
import com.baselet.element.NewGridElement;
import com.baselet.element.facet.Facet;
import com.baselet.element.facet.PropertiesParserState;
import com.baselet.element.facet.Settings;
import com.baselet.element.facet.common.SeparatorLineFacet;
import com.baselet.element.settings.SettingsManualresizeCenter;
public class ActivityObject extends NewGridElement {
@Override
public ElementId getId() {
return ElementId.UMLObject;
}
@Override
protected void drawCommonContent(PropertiesParserState state) {
state.getDrawer().drawRectangle(0, 0, getRealSize().getWidth(), getRealSize().getHeight());
}
@Override
protected Settings createSettings() {
return new SettingsManualresizeCenter() {
@Override
protected List createFacets() {
return listOf(super.createFacets(), SeparatorLineFacet.INSTANCE);
}
};
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/uml/Timer.java 0000644 0001750 0001750 00000003520 12533641120 027577 0 ustar ben ben package com.baselet.element.elementnew.uml;
import java.util.Arrays;
import com.baselet.control.basics.geom.PointDouble;
import com.baselet.control.basics.geom.Rectangle;
import com.baselet.control.enums.ElementId;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.element.NewGridElement;
import com.baselet.element.facet.PropertiesParserState;
import com.baselet.element.facet.Settings;
import com.baselet.element.settings.SettingsAutoresize;
import com.baselet.element.sticking.StickingPolygon;
import com.baselet.element.sticking.polygon.StickingPolygonGenerator;
public class Timer extends NewGridElement {
private static final int CLOCK_DIM = 40;
private final StickingPolygonGenerator timerStickingPolygonGenerator = new StickingPolygonGenerator() {
@Override
public StickingPolygon generateStickingBorder(Rectangle rect) {
StickingPolygon p = new StickingPolygon(rect.x, rect.y);
p.addPoint(xClock(), 0);
p.addPoint(x2Clock(), CLOCK_DIM);
p.addPoint(xClock(), CLOCK_DIM);
p.addPoint(x2Clock(), 0, true);
return p;
}
};
@Override
public ElementId getId() {
return ElementId.UMLTimer;
}
@Override
protected void drawCommonContent(PropertiesParserState state) {
DrawHandler drawer = state.getDrawer();
state.updateMinimumSize(CLOCK_DIM, CLOCK_DIM);
drawer.drawLines(Arrays.asList(new PointDouble(xClock(), 0), new PointDouble(x2Clock(), CLOCK_DIM), new PointDouble(xClock(), CLOCK_DIM), new PointDouble(x2Clock(), 0), new PointDouble(xClock(), 0)));
state.setStickingPolygonGenerator(timerStickingPolygonGenerator);
}
private int x2Clock() {
return xClock() + CLOCK_DIM;
}
private int xClock() {
return (getRealSize().width - CLOCK_DIM) / 2;
}
@Override
protected Settings createSettings() {
return new SettingsAutoresize();
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/uml/Deployment.java 0000644 0001750 0001750 00000004511 12533641120 030640 0 ustar ben ben package com.baselet.element.elementnew.uml;
import java.util.Arrays;
import java.util.List;
import com.baselet.control.basics.geom.PointDouble;
import com.baselet.control.enums.ElementId;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.diagram.draw.helper.ColorOwn;
import com.baselet.diagram.draw.helper.ColorOwn.Transparency;
import com.baselet.diagram.draw.helper.Style;
import com.baselet.element.NewGridElement;
import com.baselet.element.facet.Facet;
import com.baselet.element.facet.PropertiesParserState;
import com.baselet.element.facet.Settings;
import com.baselet.element.facet.common.SeparatorLineFacet;
import com.baselet.element.settings.SettingsManualResizeTop;
public class Deployment extends NewGridElement {
@Override
protected Settings createSettings() {
return new SettingsManualResizeTop() {
@Override
protected List createFacets() {
return listOf(super.createFacets(), SeparatorLineFacet.INSTANCE);
}
};
}
@Override
public ElementId getId() {
return ElementId.UMLDeployment;
}
private static final int BORDER = 10;
@Override
protected void drawCommonContent(PropertiesParserState state) {
DrawHandler drawer = state.getDrawer();
double w = getRealSize().getWidth();
double h = getRealSize().getHeight();
List p = Arrays.asList(
new PointDouble(0, BORDER),
new PointDouble(BORDER, 0),
new PointDouble(w, 0),
new PointDouble(w, h - BORDER),
new PointDouble(w - BORDER, h)
);
PointDouble pLine = new PointDouble(w - BORDER, BORDER);
// Fill 3d-rectangle
Style oldStyle = drawer.getStyleClone();
drawer.setForegroundColor(ColorOwn.TRANSPARENT);
if (oldStyle.getBackgroundColor() == ColorOwn.DEFAULT_BACKGROUND) {
drawer.setBackgroundColor(ColorOwn.WHITE.transparency(Transparency.BACKGROUND).darken(80));
}
else {
drawer.setBackgroundColor(oldStyle.getBackgroundColor().darken(80));
}
drawer.drawLines(p.get(0), p.get(1), p.get(2), p.get(3), p.get(4), pLine, p.get(0));
drawer.setStyle(oldStyle);
// Draw 3d-rectangle border
drawer.drawLines(p);
drawer.drawLines(pLine, p.get(2));
// Draw Content-Rectangle
drawer.drawRectangle(0, BORDER, w - BORDER, h - BORDER);
state.getBuffer().setTopMin(BORDER);
state.getBuffer().addToRight(BORDER);
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/uml/Note.java 0000644 0001750 0001750 00000002076 12533641120 027431 0 ustar ben ben package com.baselet.element.elementnew.uml;
import com.baselet.control.basics.geom.PointDouble;
import com.baselet.control.enums.ElementId;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.element.NewGridElement;
import com.baselet.element.facet.PropertiesParserState;
import com.baselet.element.facet.Settings;
import com.baselet.element.settings.SettingsText;
public class Note extends NewGridElement {
@Override
protected Settings createSettings() {
return new SettingsText();
}
@Override
public ElementId getId() {
return ElementId.UMLNote;
}
private static final int CORNER = 12;
@Override
protected void drawCommonContent(PropertiesParserState state) {
DrawHandler drawer = state.getDrawer();
int w = getRealSize().width;
int h = getRealSize().height;
drawer.drawLines(p(0, 0), p(w - CORNER, 0), p(w, CORNER), p(w, h), p(0, h), p(0, 0));
drawer.drawLines(p(w - CORNER, 0), p(w - CORNER, CORNER), p(w, CORNER));
}
private PointDouble p(double x, double y) {
return new PointDouble(x, y);
}
}
././@LongLink 0000644 0000000 0000000 00000000153 00000000000 011602 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/uml/SyncBarHorizontal.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/uml/SyncBarHorizonta0000644 0001750 0001750 00000003636 12533641120 031046 0 ustar ben ben package com.baselet.element.elementnew.uml;
import java.util.Set;
import com.baselet.control.basics.geom.Dimension;
import com.baselet.control.basics.geom.Rectangle;
import com.baselet.control.constants.FacetConstants;
import com.baselet.control.enums.Direction;
import com.baselet.control.enums.ElementId;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.element.NewGridElement;
import com.baselet.element.facet.PropertiesParserState;
import com.baselet.element.facet.Settings;
import com.baselet.element.settings.SettingsNoText;
import com.baselet.element.sticking.StickingPolygon;
import com.baselet.element.sticking.polygon.StickingPolygonGenerator;
public class SyncBarHorizontal extends NewGridElement {
@Override
public ElementId getId() {
return ElementId.UMLSyncBarHorizontal;
}
@Override
protected void drawCommonContent(final PropertiesParserState state) {
DrawHandler drawer = state.getDrawer();
if (drawer.getLineWidth() == FacetConstants.LINE_WIDTH_DEFAULT) {
drawer.setLineWidth(5);
}
Dimension s = getRealSize();
drawer.drawLine(0, s.getHeight() * 0.5, s.getWidth(), s.getHeight() * 0.5);
state.setStickingPolygonGenerator(new StickingPolygonGenerator() {
@Override
public StickingPolygon generateStickingBorder(Rectangle rect) {
StickingPolygon p = new StickingPolygon(rect.x, rect.y);
double lt = state.getDrawer().getLineWidth();
double halfHeight = getRealSize().getHeight() * 0.5;
p.addRectangle(new Rectangle(0.0, halfHeight - lt * 0.5, (double) getRealSize().getWidth(), lt));
return p;
}
});
}
@Override
protected Settings createSettings() {
return new SettingsNoText();
}
@Override
public Set getResizeArea(int x, int y) {
Set returnSet = super.getResizeArea(x, y);
returnSet.remove(Direction.UP);
returnSet.remove(Direction.DOWN);
return returnSet;
}
}
umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/uml/UseCase.java 0000644 0001750 0001750 00000004112 12533641120 030045 0 ustar ben ben package com.baselet.element.elementnew.uml;
import java.util.List;
import com.baselet.control.basics.XValues;
import com.baselet.control.basics.geom.Rectangle;
import com.baselet.control.enums.ElementId;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.element.NewGridElement;
import com.baselet.element.facet.Facet;
import com.baselet.element.facet.PropertiesParserState;
import com.baselet.element.facet.Settings;
import com.baselet.element.facet.common.SeparatorLineFacet;
import com.baselet.element.settings.SettingsManualresizeCenter;
import com.baselet.element.sticking.StickingPolygon;
import com.baselet.element.sticking.polygon.StickingPolygonGenerator;
public class UseCase extends NewGridElement {
private final StickingPolygonGenerator stickingPolygonGenerator = new StickingPolygonGenerator() {
@Override
public StickingPolygon generateStickingBorder(Rectangle rect) {
StickingPolygon p = new StickingPolygon(rect.x, rect.y);
p.addPoint(rect.width / 4.0, 0);
p.addPoint(rect.width * 3.0 / 4, 0);
p.addPoint(rect.width, rect.height / 4.0);
p.addPoint(rect.width, rect.height * 3.0 / 4);
p.addPoint(rect.width * 3.0 / 4, rect.height);
p.addPoint(rect.width / 4.0, rect.height);
p.addPoint(0, rect.height * 3.0 / 4);
p.addPoint(0, (int) (rect.height / 4.0), true);
return p;
}
};
@Override
public ElementId getId() {
return ElementId.UMLUseCase;
}
@Override
protected void drawCommonContent(PropertiesParserState state) {
DrawHandler drawer = state.getDrawer();
drawer.drawEllipse(0, 0, getRealSize().width, getRealSize().height);
state.setStickingPolygonGenerator(stickingPolygonGenerator);
}
@Override
protected Settings createSettings() {
return new SettingsManualresizeCenter() {
@Override
public XValues getXValues(double y, int height, int width) {
return XValues.createForEllipse(y, height, width);
}
@Override
protected List createFacets() {
return listOf(super.createFacets(), SeparatorLineFacet.INSTANCE);
}
};
}
}
././@LongLink 0000644 0000000 0000000 00000000151 00000000000 011600 L ustar root root umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/uml/SyncBarVertical.java umlet-2015-06-03_UMLet_v13.3/BaseletElements/src/com/baselet/element/elementnew/uml/SyncBarVertical.0000644 0001750 0001750 00000003632 12533641120 030714 0 ustar ben ben package com.baselet.element.elementnew.uml;
import java.util.Set;
import com.baselet.control.basics.geom.Dimension;
import com.baselet.control.basics.geom.Rectangle;
import com.baselet.control.constants.FacetConstants;
import com.baselet.control.enums.Direction;
import com.baselet.control.enums.ElementId;
import com.baselet.diagram.draw.DrawHandler;
import com.baselet.element.NewGridElement;
import com.baselet.element.facet.PropertiesParserState;
import com.baselet.element.facet.Settings;
import com.baselet.element.settings.SettingsNoText;
import com.baselet.element.sticking.StickingPolygon;
import com.baselet.element.sticking.polygon.StickingPolygonGenerator;
public class SyncBarVertical extends NewGridElement {
@Override
public ElementId getId() {
return ElementId.UMLSyncBarVertical;
}
@Override
protected void drawCommonContent(final PropertiesParserState state) {
DrawHandler drawer = state.getDrawer();
if (drawer.getLineWidth() == FacetConstants.LINE_WIDTH_DEFAULT) {
drawer.setLineWidth(5);
}
Dimension s = getRealSize();
drawer.drawLine(s.getWidth() * 0.5, 0, s.getWidth() * 0.5, s.getHeight());
state.setStickingPolygonGenerator(new StickingPolygonGenerator() {
@Override
public StickingPolygon generateStickingBorder(Rectangle rect) {
StickingPolygon p = new StickingPolygon(rect.x, rect.y);
double lt = state.getDrawer().getLineWidth();
double halfWidth = getRealSize().getWidth() * 0.5;
p.addRectangle(new Rectangle(halfWidth - lt * 0.5, 0.0, lt, (double) getRealSize().getHeight()));
return p;
}
});
}
@Override
protected Settings createSettings() {
return new SettingsNoText();
}
@Override
public Set getResizeArea(int x, int y) {
Set