Skip to content

Commit

Permalink
Fix code annotation issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Werner Randelshofer committed Apr 15, 2024
1 parent bcccb46 commit 9684a92
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
*/
public class CssSize {

public static final @Nullable CssSize ZERO = new CssSize(0);
public static final CssSize ONE = new CssSize(1);
public static final @NonNull CssSize ZERO = new CssSize(0);
public static final @NonNull CssSize ONE = new CssSize(1);
private final double value;

CssSize(double value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package org.jhotdraw8.draw.figure;

import org.jhotdraw8.annotation.NonNull;
import org.jhotdraw8.draw.connector.Connector;

/**
Expand All @@ -21,7 +22,7 @@ public interface ConnectingFigure extends Figure {
* @param connector The connector that we want to use
* @return true if the connection is supported
*/
default boolean canConnect(Figure figure, Connector connector) {
default boolean canConnect(@NonNull Figure figure, @NonNull Connector connector) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ static ImmutableSet<MapAccessor<?>> getDeclaredMapAccessors(@NonNull Class<?> cl
try {
for (Field f : clazz.getDeclaredFields()) {
if (Modifier.isStatic(f.getModifiers())
&& MapAccessor.class.isAssignableFrom(f.getType())) {
&& MapAccessor.class.isAssignableFrom(f.getType())) {
MapAccessor<?> k = (MapAccessor<?>) f.get(null);
if (k == null) {
throw new RuntimeException(clazz + " has null value for key: " + f);
Expand Down Expand Up @@ -266,14 +266,14 @@ static ImmutableSet<MapAccessor<?>> getDeclaredAndInheritedMapAccessors(Class<?>
double grow = 0.0;
if (ff.get(StrokableFigure.STROKE) != null) {
switch (ff.getNonNull(StrokableFigure.STROKE_TYPE)) {
case CENTERED:
grow += ff.getNonNull(StrokableFigure.STROKE_WIDTH).getConvertedValue() * 0.5;
break;
case INSIDE:
break;
case OUTSIDE:
grow += ff.getNonNull(StrokableFigure.STROKE_WIDTH).getConvertedValue();
break;
case CENTERED:
grow += ff.getNonNull(StrokableFigure.STROKE_WIDTH).getConvertedValue() * 0.5;
break;
case INSIDE:
break;
case OUTSIDE:
grow += ff.getNonNull(StrokableFigure.STROKE_WIDTH).getConvertedValue();
break;
}
}
if (ff.get(CompositableFigure.EFFECT) != null) {
Expand Down Expand Up @@ -385,7 +385,8 @@ default void createHandles(@NonNull HandleType handleType, @NonNull List<Handle>
* @param ctx the renderer which will use the node
* @return the newly created node
*/
@NonNull Node createNode(@NonNull RenderContext ctx);
@NonNull
Node createNode(@NonNull RenderContext ctx);

/**
* This method is invoked on a figure by
Expand Down Expand Up @@ -642,9 +643,11 @@ default void firePropertyChangeEvent(FigurePropertyChangeEvent event) {
*
* @return a list of dependent figures
*/
@NonNull Set<Figure> getLayoutObservers();
@NonNull
Set<Figure> getLayoutObservers();

@NonNull ReadOnlySet<Figure> getReadOnlyLayoutObservers();
@NonNull
ReadOnlySet<Figure> getReadOnlyLayoutObservers();

/**
* Returns the ancestor Drawing.
Expand Down Expand Up @@ -1060,7 +1063,8 @@ default void layoutChanged(@NonNull RenderContext ctx) {
* @return the parent property, with {@code getBean()} returning this
* figure, and {@code getName()} returning {@code PARENT_PROPERTY}.
*/
@NonNull ObjectProperty<Figure> parentProperty();
@NonNull
ObjectProperty<Figure> parentProperty();

/**
* Removes a child from the figure.
Expand All @@ -1071,6 +1075,16 @@ default void removeChild(Figure child) {
getChildren().remove(child);
}

/**
* Removes this figure from its parent if it has a parent.
*/
default void removeFromParent() {
Figure parent = getParent();
if (parent != null) {
parent.getChildren().remove(this);
}
}

/**
* Requests to removeChild all connection targets.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public LabelFigure(double x, double y, String text, Object... keyValues) {
}

@Override
public @NonNull TextEditorData getTextEditorDataFor(Point2D pointInLocal, Node node) {
public @NonNull TextEditorData getTextEditorDataFor(@Nullable Point2D pointInLocal, @Nullable Node node) {
return new TextEditorData(this, getLayoutBounds(), TEXT);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package org.jhotdraw8.draw.figure;

import javafx.scene.shape.PathElement;
import org.jhotdraw8.annotation.NonNull;
import org.jhotdraw8.annotation.Nullable;
import org.jhotdraw8.draw.key.DoubleStyleableKey;
import org.jhotdraw8.draw.key.NullableFXPathElementsStyleableKey;
Expand All @@ -20,7 +21,10 @@ public interface MarkerEndableFigure extends Figure {
/**
* Marker end is an SVG path that points to the right, with coordinate 0,0 at the tail of the path.
*/
@Nullable NullableFXPathElementsStyleableKey MARKER_END_SHAPE = new NullableFXPathElementsStyleableKey("marker-end-shape", null);
@NonNull
NullableFXPathElementsStyleableKey MARKER_END_SHAPE = new NullableFXPathElementsStyleableKey("marker-end-shape", null);

@NonNull
DoubleStyleableKey MARKER_END_SCALE_FACTOR = new DoubleStyleableKey("marker-end-scale-factor", 1.0);

default @Nullable ImmutableList<PathElement> getMarkerEndShape() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package org.jhotdraw8.draw.figure;

import org.jhotdraw8.annotation.Nullable;
import org.jhotdraw8.annotation.NonNull;
import org.jhotdraw8.css.value.CssSize;
import org.jhotdraw8.draw.key.CssSizeStyleableKey;
import org.jhotdraw8.draw.key.SymmetricCssPoint2DStyleableMapAccessor;
Expand All @@ -19,15 +19,19 @@ public interface StrokeCuttableFigure extends Figure {
/**
* Cuts off the specified number of pixels from the start of the stroked path.
*/
@Nullable CssSizeStyleableKey STROKE_CUT_START = new CssSizeStyleableKey("stroke-cut-start", CssSize.ZERO);
@NonNull
CssSizeStyleableKey STROKE_CUT_START = new CssSizeStyleableKey("stroke-cut-start", CssSize.ZERO);
/**
* Cuts off the specified number of pixels from the end of the stroked path.
*/
@Nullable CssSizeStyleableKey STROKE_CUT_END = new CssSizeStyleableKey("stroke-cut-end", CssSize.ZERO);
@NonNull
CssSizeStyleableKey STROKE_CUT_END = new CssSizeStyleableKey("stroke-cut-end", CssSize.ZERO);
/**
* Cuts off the specified number of pixels from the start and the end of the stroked path.
*/
@Nullable SymmetricCssPoint2DStyleableMapAccessor STROKE_CUT = new SymmetricCssPoint2DStyleableMapAccessor("stroke-cut", STROKE_CUT_START, STROKE_CUT_END);
@SuppressWarnings("unused")//This field is used by CSS stylesheets
@NonNull
SymmetricCssPoint2DStyleableMapAccessor STROKE_CUT = new SymmetricCssPoint2DStyleableMapAccessor("stroke-cut", STROKE_CUT_START, STROKE_CUT_END);

default double getStrokeCutStart() {
return getStyledNonNull(STROKE_CUT_START).getConvertedValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public interface TextStrokeableFigure extends Figure {
* <dd><a href="http://www.w3.org/TR/SVG/painting.html#StrokeProperties">w3.org</a></dd>
* </dl>
*/
@Nullable CssSizeStyleableKey TEXT_STROKE_DASH_OFFSET = new CssSizeStyleableKey("text-stroke-dashoffset", CssSize.ZERO);
@NonNull
CssSizeStyleableKey TEXT_STROKE_DASH_OFFSET = new CssSizeStyleableKey("text-stroke-dashoffset", CssSize.ZERO);
/**
* Defines the end cap style. Default value: {@code SQUARE}.
* <p>
Expand All @@ -56,6 +57,7 @@ public interface TextStrokeableFigure extends Figure {
* <dd><a href="http://www.w3.org/TR/SVG/painting.html#StrokeProperties">w3.org</a></dd>
* </dl>
*/
@NonNull
NonNullEnumStyleableKey<StrokeLineCap> TEXT_STROKE_LINE_CAP = new NonNullEnumStyleableKey<>("text-stroke-linecap", StrokeLineCap.class, StrokeLineCap.BUTT);
/**
* Defines the style applied where path segments meet. Default value:
Expand All @@ -67,6 +69,7 @@ public interface TextStrokeableFigure extends Figure {
* <dd><a href="http://www.w3.org/TR/SVG/painting.html#StrokeProperties">w3.org</a></dd>
* </dl>
*/
@NonNull
NonNullEnumStyleableKey<StrokeLineJoin> TEXT_STROKE_LINE_JOIN = new NonNullEnumStyleableKey<>("text-stroke-linejoin", StrokeLineJoin.class, StrokeLineJoin.MITER);
/**
* Defines the limit for the {@code StrokeLineJoin.MITER} style. Default
Expand All @@ -78,6 +81,7 @@ public interface TextStrokeableFigure extends Figure {
* <dd><a href="http://www.w3.org/TR/SVG/painting.html#StrokeProperties">w3.org</a></dd>
* </dl>
*/
@NonNull
CssSizeStyleableKey TEXT_STROKE_MITER_LIMIT = new CssSizeStyleableKey("text-stroke-miterlimit", CssSize.of(10.0));
/**
* Defines the paint used for filling the outline of the figure. Default
Expand All @@ -89,12 +93,14 @@ public interface TextStrokeableFigure extends Figure {
* <dd><a href="http://www.w3.org/TR/SVG/painting.html#StrokeProperties">w3.org</a></dd>
* </dl>
*/
@Nullable NullablePaintableStyleableKey TEXT_STROKE = new NullablePaintableStyleableKey("text-stroke", null);
@NonNull
NullablePaintableStyleableKey TEXT_STROKE = new NullablePaintableStyleableKey("text-stroke", null);
/**
* Defines the stroke type used for drawing outline of the figure.
* <p>
* Default value: {@code StrokeType.OUTSIDE}.
*/
@NonNull
NonNullEnumStyleableKey<StrokeType> TEXT_STROKE_TYPE = new NonNullEnumStyleableKey<>("text-stroke-type", StrokeType.class, StrokeType.OUTSIDE);
/**
* Defines the width of the outline of the figure.
Expand All @@ -107,6 +113,7 @@ public interface TextStrokeableFigure extends Figure {
* <dd><a href="http://www.w3.org/TR/SVG/painting.html#StrokeProperties">w3.org</a></dd>
* </dl>
*/
@NonNull
CssSizeStyleableKey TEXT_STROKE_WIDTH = new CssSizeStyleableKey("text-stroke-width", CssSize.ONE);

/**
Expand All @@ -118,14 +125,17 @@ public interface TextStrokeableFigure extends Figure {
* <dd><a href="http://www.w3.org/TR/SVG/painting.html#StrokeProperties">w3.org</a></dd>
* </dl>
*/
@NonNull
NonNullListStyleableKey<CssSize> TEXT_STROKE_DASH_ARRAY = new NonNullListStyleableKey<>("text-stroke-dasharray",
CssSize.class,
new SizeCssConverter(false), VectorList.of());

/**
* Combined map accessor for all stroke style properties.
*/
@Nullable StrokeStyleableMapAccessor TEXT_STROKE_STYLE = new StrokeStyleableMapAccessor("text-stroke-style",
@SuppressWarnings("unused")//Field is accessed by CSS using Reflection
@NonNull
StrokeStyleableMapAccessor TEXT_STROKE_STYLE = new StrokeStyleableMapAccessor("text-stroke-style",
TEXT_STROKE_TYPE, TEXT_STROKE_LINE_CAP, TEXT_STROKE_LINE_JOIN, TEXT_STROKE_MITER_LIMIT, TEXT_STROKE_DASH_OFFSET, TEXT_STROKE_DASH_ARRAY);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import javafx.geometry.Point2D;
import javafx.scene.transform.Transform;
import org.jhotdraw8.annotation.NonNull;
import org.jhotdraw8.annotation.Nullable;

/**
* TransformPathBuilder.
Expand Down Expand Up @@ -75,7 +74,7 @@ public void setTransform(@NonNull Transform transform) {
}

@Override
public @Nullable T build() {
public T build() {
return target.build();
}
}

0 comments on commit 9684a92

Please sign in to comment.