Skip to content

Commit

Permalink
[#523] Code cleanup
Browse files Browse the repository at this point in the history
* Remove rendundant type parameters
* Remove parenthesis padding before for and if
  • Loading branch information
prmr committed May 6, 2024
1 parent e8c20fa commit d9a189a
Show file tree
Hide file tree
Showing 34 changed files with 168 additions and 168 deletions.
2 changes: 1 addition & 1 deletion src/org/jetuml/application/Clipboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public boolean validPaste(Diagram pDiagram)
private static boolean validElementFor( DiagramElement pElement, Diagram pDiagram )
{
// PointNodes are allowed in all diagrams despite not being contained in prototypes.
if ( pElement.getClass() == PointNode.class )
if( pElement.getClass() == PointNode.class )
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/org/jetuml/diagram/builder/DiagramBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ private Point computePosition(Dimension pDimension, Point pRequestedPosition)
{
newX = aCanvasDimension.width() - pDimension.width();
}
if (newY + pDimension.height() > aCanvasDimension.height())
if(newY + pDimension.height() > aCanvasDimension.height())
{
newY = aCanvasDimension.height() - pDimension.height();
}
Expand Down
8 changes: 4 additions & 4 deletions src/org/jetuml/diagram/builder/SequenceDiagramBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ else if(pElement instanceof Edge)
}
result.addAll(getCorrespondingReturnEdges(result));
//Implicit parameter nodes downstream of constructor calls should not be removed
if (pElement instanceof ConstructorEdge)
if(pElement instanceof ConstructorEdge)
{
result.removeIf(element -> element instanceof ImplicitParameterNode);
}
Expand Down Expand Up @@ -242,7 +242,7 @@ private boolean isConstructorExecution(Node pNode)
}
for( Edge edge : diagram().edges() )
{
if ( edge.end() == pNode && edge.getClass() == ConstructorEdge.class )
if( edge.end() == pNode && edge.getClass() == ConstructorEdge.class )
{
return true;
}
Expand Down Expand Up @@ -346,7 +346,7 @@ private Optional<Edge> getConstructorEdge(Node pNode)
}
for( Edge edge : diagram().edges() )
{
if ( edge.end() == pNode && edge.getClass() == ConstructorEdge.class )
if( edge.end() == pNode && edge.getClass() == ConstructorEdge.class )
{
return Optional.of(edge);
}
Expand Down Expand Up @@ -434,7 +434,7 @@ else if( pNode.getClass() == CallNode.class )
downstreamElements.addAll(getEdgeDownStreams(edge));
}
}
else if ( pNode.getClass() == ImplicitParameterNode.class )
else if( pNode.getClass() == ImplicitParameterNode.class )
{
downstreamElements.addAll(pNode.getChildren());
for( Node child: pNode.getChildren() )
Expand Down
14 changes: 7 additions & 7 deletions src/org/jetuml/geom/EdgePath.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public EdgePath(Line...pLines)
{
assert pLines.length > 0;
aPoints.add(pLines[0].getPoint1());
for (Line line : pLines)
for(Line line : pLines)
{
aPoints.add(line.getPoint2());
}
Expand Down Expand Up @@ -99,26 +99,26 @@ public int hashCode()
@Override
public boolean equals(Object pObj)
{
if (this == pObj)
if(this == pObj)
{
return true;
}
if (pObj == null)
if(pObj == null)
{
return false;
}
if (getClass() != pObj.getClass())
if(getClass() != pObj.getClass())
{
return false;
}
EdgePath other = (EdgePath) pObj;
if (other.aPoints.size() != this.aPoints.size())
if(other.aPoints.size() != this.aPoints.size())
{
return false;
}
for (int i = 0; i < aPoints.size(); i++)
for(int i = 0; i < aPoints.size(); i++)
{
if (!other.aPoints.get(i).equals(aPoints.get(i)))
if(!other.aPoints.get(i).equals(aPoints.get(i)))
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/org/jetuml/gui/AboutDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private Scene createScene()
aStage.requestFocus();
aStage.addEventHandler(KeyEvent.KEY_PRESSED, pEvent ->
{
if (pEvent.getCode() == KeyCode.ENTER)
if(pEvent.getCode() == KeyCode.ENTER)
{
aStage.close();
}
Expand Down
12 changes: 6 additions & 6 deletions src/org/jetuml/gui/DiagramCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public void paste()
*/
private static void shiftElements(Iterable<DiagramElement> pElements, int pShiftAmount)
{
for (DiagramElement element: pElements)
for(DiagramElement element: pElements)
{
if(element instanceof Node)
{
Expand Down Expand Up @@ -362,7 +362,7 @@ public void booleanPreferenceChanged(BooleanPreference pPreference)
@Override
public void integerPreferenceChanged(IntegerPreference pPreference)
{
if ( pPreference == IntegerPreference.fontSize )
if( pPreference == IntegerPreference.fontSize )
{
paintPanel();
}
Expand Down Expand Up @@ -628,19 +628,19 @@ private void alignMoveToGrid()
int dy = snappedPosition.getY() - bounds.getY();

//ensure the bounds of the entire selection are not outside the walls of the canvas
if (entireBounds.getMaxX() + dx > getWidth())
if(entireBounds.getMaxX() + dx > getWidth())
{
dx -= GRID_SIZE;
}
else if (entireBounds.getX() + dx <= 0)
else if(entireBounds.getX() + dx <= 0)
{
dx += GRID_SIZE;
}
if (entireBounds.getMaxY() + dy > getHeight())
if(entireBounds.getMaxY() + dy > getHeight())
{
dy -= GRID_SIZE;
}
else if (entireBounds.getY() <= 0)
else if(entireBounds.getY() <= 0)
{
dy += GRID_SIZE;
}
Expand Down
8 changes: 4 additions & 4 deletions src/org/jetuml/gui/EditorFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ private void close()
alert.setHeaderText(RESOURCES.getString("dialog.close.title"));
alert.showAndWait();

if (alert.getResult() == ButtonType.YES)
if(alert.getResult() == ButtonType.YES)
{
removeGraphFrameFromTabbedPane(diagramTab);
}
Expand Down Expand Up @@ -451,7 +451,7 @@ public void close(DiagramTab pDiagramTab)
alert.setHeaderText(RESOURCES.getString("dialog.close.title"));
alert.showAndWait();

if (alert.getResult() == ButtonType.YES)
if(alert.getResult() == ButtonType.YES)
{
removeGraphFrameFromTabbedPane(pDiagramTab);
}
Expand Down Expand Up @@ -655,7 +655,7 @@ private int getNumberOfUsavedDiagrams()
public void exit()
{
final int modcount = getNumberOfUsavedDiagrams();
if (modcount > 0)
if(modcount > 0)
{
Alert alert = new Alert(AlertType.CONFIRMATION,
MessageFormat.format(RESOURCES.getString("dialog.exit.ok"), new Object[] { Integer.valueOf(modcount) }),
Expand All @@ -666,7 +666,7 @@ public void exit()
alert.setHeaderText(RESOURCES.getString("dialog.exit.title"));
alert.showAndWait();

if (alert.getResult() == ButtonType.YES)
if(alert.getResult() == ButtonType.YES)
{
Preferences.userNodeForPackage(JetUML.class).put("recent", aRecentFiles.serialize());
System.exit(0);
Expand Down
12 changes: 6 additions & 6 deletions src/org/jetuml/gui/NotificationService.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ public static NotificationService instance()
*/
public void setMainStage(Stage pStage)
{
this.aMainStage = pStage;
aMainStage = pStage;

if (pStage != null)
if(pStage != null)
{
// Window position and size listener for notifications
ChangeListener<Number> stageTransformationListener = (pObservableValue, pOldValue, pNewValue) ->
Expand All @@ -100,12 +100,12 @@ public void updateNotificationPosition()

ArrayList<Notification> reverseNotifications = new ArrayList<>(aNotifications);
Collections.reverse(reverseNotifications);
for (Notification notification : reverseNotifications)
for(Notification notification : reverseNotifications)
{
notification.setPosition(x, y);
y = y - notification.getHeight() - NOTIFICATION_DISPLAY_SPACING;

if (y < aMainStage.getY())
if(y < aMainStage.getY())
{
notification.close();
aNotifications.remove(notification);
Expand All @@ -120,7 +120,7 @@ public void updateNotificationPosition()
*/
public void spawnNotification(Notification pNotification)
{
if (aMainStage == null)
if(aMainStage == null)
{
return;
}
Expand All @@ -144,7 +144,7 @@ public void spawnNotification(Notification pNotification)
*/
public void spawnNotification(String pText, ToastNotification.Type pType)
{
if (aMainStage == null)
if(aMainStage == null)
{
return;
}
Expand Down
8 changes: 4 additions & 4 deletions src/org/jetuml/gui/PropertySheet.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,18 @@ private static void addTabbingFeature(TextArea pTextArea)
{
final String aFocusEventText = "TAB_TO_FOCUS_EVENT";

if (!KeyCode.TAB.equals(pKeyEvent.getCode()))
if(!KeyCode.TAB.equals(pKeyEvent.getCode()))
{
return;
}
if (pKeyEvent.isAltDown() || pKeyEvent.isMetaDown() || pKeyEvent.isShiftDown() || !(pKeyEvent.getSource() instanceof TextArea))
if(pKeyEvent.isAltDown() || pKeyEvent.isMetaDown() || pKeyEvent.isShiftDown() || !(pKeyEvent.getSource() instanceof TextArea))
{
return;
}
final TextArea textAreaSource = (TextArea) pKeyEvent.getSource();
if (pKeyEvent.isControlDown())
if(pKeyEvent.isControlDown())
{
if (!aFocusEventText.equalsIgnoreCase(pKeyEvent.getText()))
if(!aFocusEventText.equalsIgnoreCase(pKeyEvent.getText()))
{
pKeyEvent.consume();
textAreaSource.replaceSelection("\t");
Expand Down
2 changes: 1 addition & 1 deletion src/org/jetuml/gui/tips/TipDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private Scene createScene()
aStage.requestFocus();
aStage.addEventHandler(KeyEvent.KEY_PRESSED, pEvent ->
{
if (pEvent.getCode() == KeyCode.ESCAPE)
if(pEvent.getCode() == KeyCode.ESCAPE)
{
aStage.close();
}
Expand Down
6 changes: 3 additions & 3 deletions src/org/jetuml/gui/tips/TipLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private static String inputStreamToString(InputStream pStream) throws IOExceptio
{
ByteArrayOutputStream result = new ByteArrayOutputStream();
byte[] buffer = new byte[BYTES_IN_KILOBYTE];
for (int length; (length = pStream.read(buffer)) != -1; )
for(int length; (length = pStream.read(buffer)) != -1; )
{
result.write(buffer, 0, length);
}
Expand Down Expand Up @@ -138,7 +138,7 @@ private static List<TipElement> convertJsonObjectToTipElements(JsonObject pTip)
{
List<TipElement> elements = new ArrayList<>();

for (Object contentObject : pTip.getJsonArray(TipFieldName.CONTENT.asString()))
for(Object contentObject : pTip.getJsonArray(TipFieldName.CONTENT.asString()))
{
JsonObject contentJsonObject = (JsonObject) contentObject;
Media media = discoverMediaUsed(contentJsonObject);
Expand All @@ -153,7 +153,7 @@ private static List<TipElement> convertJsonObjectToTipElements(JsonObject pTip)
*/
private static Media discoverMediaUsed(JsonObject pTipContent)
{
for (Media media : Media.values())
for(Media media : Media.values())
{
if(pTipContent.hasProperty(media.name().toLowerCase()))
{
Expand Down
10 changes: 5 additions & 5 deletions src/org/jetuml/gui/tips/ViewedTips.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public ViewedTips(int pFirstTipOfTheDayId)

aCurrentTipId = pFirstTipOfTheDayId;

if (pFirstTipOfTheDayId == NUM_TIPS)
if(pFirstTipOfTheDayId == NUM_TIPS)
{
aNewNextTipOfTheDayId = 1;
}
Expand Down Expand Up @@ -86,7 +86,7 @@ public int getNewNextTipOfTheDayId()

private void updateCurrentTipIdToNextTipId()
{
if (aCurrentTipId == NUM_TIPS)
if(aCurrentTipId == NUM_TIPS)
{
aCurrentTipId = 1;
}
Expand All @@ -98,7 +98,7 @@ private void updateCurrentTipIdToNextTipId()

private void updateCurrentTipIdToPreviousTipId()
{
if (aCurrentTipId == 1)
if(aCurrentTipId == 1)
{
aCurrentTipId = NUM_TIPS;
}
Expand All @@ -114,9 +114,9 @@ private void updateCurrentTipIdToPreviousTipId()
*/
private void updateNextTipOfTheDayId()
{
if (aCurrentTipId == aNewNextTipOfTheDayId)
if(aCurrentTipId == aNewNextTipOfTheDayId)
{
if (aNewNextTipOfTheDayId == NUM_TIPS)
if(aNewNextTipOfTheDayId == NUM_TIPS)
{
aNewNextTipOfTheDayId = 1;
}
Expand Down
6 changes: 3 additions & 3 deletions src/org/jetuml/persistence/json/CharacterBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void skipBlanks()
while (hasMore())
{
char character = next();
if (!isWhitespace(character))
if(!isWhitespace(character))
{
backUp();
return;
Expand Down Expand Up @@ -131,11 +131,11 @@ boolean isNext(char pCharacter)
@Override
public String toString()
{
if (aPosition >= 0 && aPosition < aCharacters.length())
if(aPosition >= 0 && aPosition < aCharacters.length())
{
return String.format("At position %d [%s]", aPosition, aCharacters.charAt(aPosition));
}
else if (aPosition < 0)
else if(aPosition < 0)
{
return "Positioned at the beginning";
}
Expand Down
2 changes: 1 addition & 1 deletion src/org/jetuml/persistence/json/JsonIntegerParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class JsonIntegerParser implements JsonValueParser
@Override
public boolean isApplicable(ParsableCharacterBuffer pInput)
{
if (!pInput.hasMore() )
if(!pInput.hasMore() )
{
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions src/org/jetuml/persistence/json/JsonStringParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ else if( next == CHAR_UNICODE_ESCAPE )
*/
private static char parseUnicode(ParsableCharacterBuffer pInput)
{
if (!pInput.hasMore(NUMBER_OF_UNICODE_DIGITS))
if(!pInput.hasMore(NUMBER_OF_UNICODE_DIGITS))
{
throw new JsonParsingException(pInput.position());
}
Expand Down Expand Up @@ -141,16 +141,16 @@ public String parse(ParsableCharacterBuffer pInput)
while (pInput.hasMore())
{
char next = pInput.next();
if (isISOControl(next))
if(isISOControl(next))
{
throw new JsonParsingException(pInput.position());
}
else if (next == CHAR_ESCAPE)
else if(next == CHAR_ESCAPE)
{
pInput.backUp();
result.append(parseEscape(pInput));
}
else if (next == CHAR_QUOTE)
else if(next == CHAR_QUOTE)
{
return result.toString();
}
Expand Down
Loading

0 comments on commit d9a189a

Please sign in to comment.