6767import static pixelitor .io .FileUtils .removeExtension ;
6868import static pixelitor .layers .LayerAdder .Position .ABOVE_ACTIVE ;
6969import static pixelitor .layers .LayerAdder .Position .BELOW_ACTIVE ;
70+ import static pixelitor .utils .Threads .callInfo ;
7071import static pixelitor .utils .Threads .calledOnEDT ;
7172import static pixelitor .utils .Threads .onEDT ;
7273import static pixelitor .utils .Threads .onIOThread ;
73- import static pixelitor .utils .Threads .threadInfo ;
7474import static pixelitor .utils .Utils .createCopyName ;
7575import static pixelitor .utils .debug .DebugNodes .createBufferedImageNode ;
7676
@@ -88,7 +88,7 @@ public class Composition implements Serializable, ImageSource, LayerHolder {
8888
8989 private final List <Layer > layerList = new ArrayList <>();
9090
91- // The currently selected layer, potentially nested within groups or smart objects.
91+ // the currently selected layer, potentially nested within groups or smart objects
9292 private Layer activeLayer ;
9393
9494 // The top-level ancestor layer of the activeLayer.
@@ -131,8 +131,8 @@ public class Composition implements Serializable, ImageSource, LayerHolder {
131131
132132 private transient Selection selection ;
133133
134- // A temporary selection that is currently being created
135- // by dragging, but it's not finalized yet.
134+ // a temporary selection that is currently being created
135+ // by dragging, but it's not finalized yet
136136 private transient Selection draftSelection ;
137137
138138 /**
@@ -208,7 +208,7 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE
208208
209209 activeTopLevelLayer = activeLayer .getTopLevelLayer ();
210210
211- // Perform actions that need a full canvas and also
211+ // perform actions that need a full canvas and also
212212 // (re)load the contents of linked smart objects
213213 forEachNestedLayerOfType (CompositeLayer .class , CompositeLayer ::afterDeserialization );
214214
@@ -375,8 +375,8 @@ public void addOwner(SmartObject newOwner) {
375375 * Checks if this {@link Composition} is the content of any {@link SmartObject}.
376376 */
377377 public boolean isSmartObjectContent () {
378- // If a content file is opened independently of its parent,
379- // then this will return false, even for PXC files!
378+ // if a content file is opened independently of its parent,
379+ // then this will return false, even for PXC files
380380 return owners != null ;
381381 }
382382
@@ -509,8 +509,7 @@ public void setName(String name) {
509509 }
510510
511511 /**
512- * Create a file name that will be suggested as the default
513- * file name in the save dialog.
512+ * Creates a file name to suggest in the save dialog.
514513 */
515514 public String suggestFileName (String extension ) {
516515 if (file == null ) {
@@ -546,7 +545,7 @@ public void rename(String oldName, String newName) {
546545 return ;
547546 }
548547 setName (newName );
549- History .add (new CompositionRenamedEdit (this , oldName , newName ));
548+ History .add (new CompositionRenameEdit (this , oldName , newName ));
550549 }
551550
552551 public String getDebugName () {
@@ -660,6 +659,7 @@ public void flattenImage() {
660659 return ;
661660 }
662661
662+ // create the new flattened layer from the composite of visible layers
663663 BufferedImage flattenedImg = getCompositeImage ();
664664 Layer flattenedLayer = new ImageLayer (this , flattenedImg , "flattened" );
665665
@@ -865,8 +865,8 @@ public void setActiveLayer(Layer layer, boolean addToHistory, String editName) {
865865 Layer prevActiveLayer = this .activeLayer ;
866866 this .activeLayer = layer ;
867867
868- // After ungrouping a group with a single active layer,
869- // the active layer could change without a change in the target.
868+ // after ungrouping a group with a single active layer,
869+ // the active layer could change without a change in the target
870870 setActiveTopLevelLayer (layer .getTopLevelLayer ());
871871
872872 if (this .activeLayer == prevActiveLayer ) {
@@ -1015,8 +1015,7 @@ public void forEachNestedLayerAndMask(Consumer<Layer> action) {
10151015 }
10161016
10171017 /**
1018- * Applies an action to all nested layers.
1019- * Traverses both layer group hierarchy and smart object content hierarchy.
1018+ * Applies an action to all nested layers, traversing groups and smart objects.
10201019 */
10211020 public void forEachNestedLayer (Consumer <Layer > action , boolean includeMasks ) {
10221021 for (Layer layer : layerList ) {
@@ -1054,7 +1053,7 @@ public Layer findLayerAtPoint(Point2D p) {
10541053
10551054 Point pixelLoc = new Point ((int ) p .getX (), (int ) p .getY ());
10561055
1057- // iterate in reverse order (we need to search layers from top to bottom)
1056+ // iterate in reverse order to search layers from top to bottom
10581057 ListIterator <Layer > li = layerList .listIterator (layerList .size ());
10591058 while (li .hasPrevious ()) {
10601059 Layer layer = li .previous ();
@@ -1099,7 +1098,7 @@ private Layer getActiveTarget() {
10991098 }
11001099
11011100 /**
1102- * Returns the active mask or image layer or null
1101+ * Returns the active {@link Drawable} ( layer or mask), or null if none is active.
11031102 */
11041103 public Drawable getActiveDrawable () {
11051104 assert checkInvariants ();
@@ -1112,6 +1111,9 @@ public Drawable getActiveDrawable() {
11121111 }
11131112 }
11141113
1114+ /**
1115+ * Returns the active {@link Filterable} (layer or mask), or null if none is active.
1116+ */
11151117 public Filterable getActiveFilterable () {
11161118 assert checkInvariants ();
11171119 if (activeLayer .isMaskEditing ()) {
@@ -1124,8 +1126,7 @@ public Filterable getActiveFilterable() {
11241126 }
11251127
11261128 /**
1127- * Returns the active mask or image layer.
1128- * Calling this method assumes that the active layer is a {@link Drawable}.
1129+ * Returns the active {@link Drawable} (layer or mask), or throws an exception if none is active.
11291130 */
11301131 public Drawable getActiveDrawableOrThrow () {
11311132 Drawable dr = getActiveDrawable ();
@@ -1503,15 +1504,13 @@ public void intersectSelectionWith(Rectangle2D rect) {
15031504 * might not be open in a view.
15041505 */
15051506 public void imCoordsChanged (AffineTransform at , boolean isUndoRedo , View view ) {
1506- // The selection is explicitly reset to a backup shape
1507- // when something is undone/redone.
1507+ // the selection is explicitly reset to a backup shape
1508+ // when something is undone/redone
15081509 if (selection != null && !isUndoRedo ) {
15091510 selection .transform (at );
15101511 }
1511- // The paths and the tool widgets are transformed even for undo/redo.
1512- // The advantage is simpler code, the disadvantage is that
1513- // rounding errors could accumulate if the same operation is
1514- // undone/redone many times.
1512+
1513+ // the paths and the tool widgets are transformed even for undo/redo
15151514 if (paths != null ) {
15161515 paths .imCoordsChanged (at );
15171516 }
@@ -1616,9 +1615,7 @@ public void activeLayerToCanvasSize() {
16161615 }
16171616
16181617 /**
1619- * Fits the canvas to the combined bounds of all content layers.
1620- * If any content layer is larger than the current canvas, the
1621- * canvas will be enlarged to fully contain all content layers.
1618+ * Enlarges the canvas to fit the content of all layers.
16221619 */
16231620 public void fitCanvasToLayers () {
16241621 Outsets enlargement = Outsets .createZero ();
@@ -1747,7 +1744,7 @@ public boolean checkInvariants() {
17471744 */
17481745 public CompletableFuture <Void > saveAsync (SaveSettings saveSettings ,
17491746 boolean addToRecentFiles ) {
1750- assert calledOnEDT () : threadInfo ();
1747+ assert calledOnEDT () : callInfo ();
17511748
17521749 // prevent concurrent processing of the same file path
17531750 File targetFile = saveSettings .file ();
@@ -1759,7 +1756,7 @@ public CompletableFuture<Void> saveAsync(SaveSettings saveSettings,
17591756 }
17601757 IOTasks .markPathForWriting (filePath );
17611758
1762- // Set to not dirty already at the beginning of the saving process,
1759+ // set to not dirty already at the beginning of the saving process,
17631760 // so that subsequent closing doesn't trigger another save.
17641761 boolean wasDirty = isDirty ();
17651762 clearDirtyFlagsRecursively ();
@@ -1786,7 +1783,7 @@ public CompletableFuture<Void> saveAsync(SaveSettings saveSettings,
17861783 * Actions to perform on the EDT after a successful save.
17871784 */
17881785 public void handleSuccessfulSave (File file , boolean addToRecentFiles ) {
1789- assert calledOnEDT () : threadInfo ();
1786+ assert calledOnEDT () : callInfo ();
17901787
17911788 setFile (file );
17921789 if (addToRecentFiles ) {
@@ -1796,8 +1793,8 @@ public void handleSuccessfulSave(File file, boolean addToRecentFiles) {
17961793 Messages .showFileSavedMessage (file );
17971794
17981795 if (isSmartObjectContent ()) {
1799- // Otherwise the changes might not be propagated when deactivating,
1800- // because this isn't dirty after saving even if it's changed.
1796+ // otherwise the changes might not be propagated when deactivating,
1797+ // because this isn't dirty after saving even if it's changed
18011798 for (SmartObject owner : owners ) {
18021799 owner .propagateContentChanges (this , true );
18031800
@@ -1914,7 +1911,7 @@ public ImageMode getMode() {
19141911 * need to be reloaded due to external file modifications.
19151912 */
19161913 public CompletableFuture <Composition > checkForExternalModifications () {
1917- // check only the open compositions here - hidden
1914+ // check only the open compositions here; hidden
19181915 // smart object contents will be checked later
19191916 if (file != null && isOpen ()) {
19201917 long currentFileTimestamp = file .lastModified ();
0 commit comments