Skip to content

Commit

Permalink
both direction is a illegal direction
Browse files Browse the repository at this point in the history
  • Loading branch information
TruongQuangSB committed Dec 10, 2024
1 parent 14ba267 commit 327fd64
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ class SsksTransformator extends AbstractPlanPro2TableModelTransformator {
]
waitingFileSideDistanceSignal.put(row, signal)
} else {
val abstandMastmitteLinks = new HashSet<Pair<Long, Long>>
val abstandMastmitteRechts = new HashSet<Pair<Long, Long>>
val abstandMastmitteLinks = new HashSet<Pair<String, String>>
val abstandMastmitteRechts = new HashSet<Pair<String, String>>

signal.initAbstandMastmitte(signal.signalRahmen,
abstandMastmitteLinks, abstandMastmitteRechts);
Expand All @@ -364,7 +364,7 @@ class SsksTransformator extends AbstractPlanPro2TableModelTransformator {
signal,
[
abstandMastmitteLinks.map [
'''«key»«IF value > 0» («value»)«ENDIF»'''
'''«key»«IF value !== null» («value»)«ENDIF»'''
]
],
null,
Expand All @@ -377,11 +377,10 @@ class SsksTransformator extends AbstractPlanPro2TableModelTransformator {
signal,
[
abstandMastmitteRechts.map [
'''«key»«IF value > 0» («value»)«ENDIF»'''
'''«key»«IF value !== null» («value»)«ENDIF»'''
]
],
null,
[toString]
null
)
}

Expand Down Expand Up @@ -918,28 +917,28 @@ class .simpleName»: «e.message» - failed to transform table contents''', e)

private def void refillSideDistance(TableRow row, Signal signal,
List<Pt1TableChangeProperties> changeProperties) {
val abstandMastmitteLinks = new HashSet<Pair<Long, Long>>
val abstandMastmitteRechts = new HashSet<Pair<Long, Long>>
val abstandMastmitteLinks = new HashSet<Pair<String, String>>
val abstandMastmitteRechts = new HashSet<Pair<String, String>>
val containerType = signal.container.containerType
signal.initAbstandMastmitte(signal.signalRahmen, abstandMastmitteLinks,
abstandMastmitteRechts);
val leftDistance = new Pt1TableChangeProperties(containerType, row,
cols.getColumn(Mastmitte_Links), abstandMastmitteLinks.map [
'''«key» «IF value > 0»(«value»)«ENDIF»'''
'''«key» «IF value !== null»(«value»)«ENDIF»'''
].toList, ITERABLE_FILLING_SEPARATOR)
changeProperties.add(leftDistance)
val rightDistance = new Pt1TableChangeProperties(containerType, row,
cols.getColumn(Mastmitte_Rechts), abstandMastmitteRechts.map [
'''«key» «IF value > 0»(«value»)«ENDIF»'''
'''«key» «IF value !== null»(«value»)«ENDIF»'''
].toList, ITERABLE_FILLING_SEPARATOR)
changeProperties.add(rightDistance)
}

private def void initAbstandMastmitte(
Signal signal,
List<Signal_Rahmen> signalRahmen,
Set<Pair<Long, Long>> abstandMastmitteLinks,
Set<Pair<Long, Long>> abstandMastmitteRechts
Set<Pair<String, String>> abstandMastmitteLinks,
Set<Pair<String, String>> abstandMastmitteRechts
) {
signalRahmen.map [
signalBefestigungIterator.findFirst [
Expand All @@ -949,24 +948,32 @@ class .simpleName»: «e.message» - failed to transform table contents''', e)
ENUM_BEFESTIGUNG_ART_REGELANORDNUNG_MAST_NIEDRIG
]
].filterNull.map[singlePoints].flatten.toSet.forEach [ p |
val seitlicherAbstand = Math.round(
p.seitlicherAbstand.wert.doubleValue * 1000)
if (p?.seitlicherAbstand?.wert === null) {
val exception = new NullPointerException(
"The Signal_Befestigung haven't seitlicherAbstand")
abstandMastmitteLinks.add(
exception.createErrorMsg(signal.identitaet.wert) -> null)
abstandMastmitteRechts.add(
exception.createErrorMsg(signal.identitaet.wert) -> null)
return
}
val seitlicherAbstand = Math.round(p.seitlicherAbstand.wert.doubleValue * 1000)
val wirkrichtung = p.wirkrichtung.wert
val distanceFromPoint = MAX_OPOSIDE_DISTANCE -
Math.abs(seitlicherAbstand)
var perpendicularRotation = 0

switch (wirkrichtung) {
case ENUM_WIRKRICHTUNG_IN,
case ENUM_WIRKRICHTUNG_BEIDE:
perpendicularRotation = seitlicherAbstand >= 0 ? 90 : -90
case ENUM_WIRKRICHTUNG_GEGEN:
perpendicularRotation = seitlicherAbstand < 0 ? 90 : -90
default: {
LOGGER.error("Illegal Wirkrichtung")
return
}
if (wirkrichtung !== ENUM_WIRKRICHTUNG_IN &&
wirkrichtung !== ENUM_WIRKRICHTUNG_GEGEN) {
val exception = new IllegalArgumentException(
"The Signal_Befestigung have Illegal Wirkrichtung")
abstandMastmitteLinks.add(
exception.createErrorMsg(signal.identitaet.wert) -> null)
abstandMastmitteRechts.add(
exception.createErrorMsg(signal.identitaet.wert) -> null)
return
}
val isLeftsideOfTrack = (wirkrichtung === ENUM_WIRKRICHTUNG_IN) ===
(seitlicherAbstand >= 0)
val perpendicularRotation = isLeftsideOfTrack ? 90 : -90
var opposideSideDistance = 0.0
val geoPosition = Services.pointObjectService.getCoordinate(p).
geoPosition
Expand All @@ -977,24 +984,18 @@ class .simpleName»: «e.message» - failed to transform table contents''', e)
LOGGER.error(e.message)
}
val distanceBetweenTracks = opposideSideDistance > 0
? Math.abs(seitlicherAbstand) +
Math.round(opposideSideDistance * 1000)
: 0

switch (wirkrichtung) {
case ENUM_WIRKRICHTUNG_IN,
case ENUM_WIRKRICHTUNG_BEIDE:
seitlicherAbstand >= 0
? abstandMastmitteLinks.add(
Math.abs(seitlicherAbstand) -> distanceBetweenTracks)
: abstandMastmitteRechts.add(
Math.abs(seitlicherAbstand) -> distanceBetweenTracks)
case ENUM_WIRKRICHTUNG_GEGEN:
seitlicherAbstand < 0
? abstandMastmitteLinks.add(
Math.abs(seitlicherAbstand) -> distanceBetweenTracks)
: abstandMastmitteRechts.add(
Math.abs(seitlicherAbstand) -> distanceBetweenTracks)
? (Math.abs(seitlicherAbstand) +
Math.round(opposideSideDistance * 1000)).toString
: null

if (isLeftsideOfTrack) {
abstandMastmitteLinks.add(
Math.abs(seitlicherAbstand).toString ->
distanceBetweenTracks)
} else {
abstandMastmitteRechts.add(
Math.abs(seitlicherAbstand).toString ->
distanceBetweenTracks)
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ class CellContentExtensions {
return '''<span>«value.htmlString»</span>'''
}
case WARNING_MARK_YELLOW: {
return '''<span style="background-color:rgb(255,255, 0)"><s>«value.htmlString»</s></span>'''
return '''<span style="background-color:rgb(255,255, 0)">«value.htmlString»</span>'''
}
case WARNING_MARK_RED: {
return '''<span style="color:rgb(255, 0, 0)">«value.htmlString»</span>'''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public Rectangle getDecoratorCellPainterBounds(final ILayerCell cell,
configRegistry)
: 0;

switch (getCellEdge()) {
switch (super.getCellEdge()) {
case LEFT:
return new Rectangle(adjustedCellBounds.x, adjustedCellBounds.y,
preferredDecoratorWidth, preferredDecoratorHeight)
Expand All @@ -90,7 +90,7 @@ public Rectangle getDecoratorCellPainterBounds(final ILayerCell cell,
case RIGHT:
return new Rectangle(adjustedCellBounds.x,
adjustedCellBounds.y + preferredBaseHeight
- preferredDecoratorHeight,
- getSpacing(),
preferredDecoratorWidth, preferredDecoratorHeight)
.intersection(adjustedCellBounds);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
import org.eclipse.nebula.widgets.nattable.painter.cell.BackgroundPainter;
import org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter;
import org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator;
import org.eclipse.swt.graphics.Image;

import org.eclipse.set.model.tablemodel.extensions.CellContentExtensions;
import org.eclipse.swt.graphics.Image;

/**
* Painter used to draw PlanPro table cells.
Expand All @@ -30,27 +29,27 @@ public class PlanProTableCellPainter extends BackgroundPainter {
/**
* @param interiorPainter
* the interior painter
* @param leftWarningImage
* the left warning image
* @param rightWarningImage
* the right warning image
* @param yellowWarningImage
* the yellow warning image
* @param redWarningImage
* the red warning image
* @param blackWarningImage
* the black warning image
*/
public PlanProTableCellPainter(final ICellPainter interiorPainter,
final Image leftWarningImage, final Image rightWarningImage,
final Image yellowWarningImage, final Image redWarningImage,
final Image blackWarningImage) {
super(new PaddingDecorator(new BasePainterDecorator(
new BasePainterDecorator(new BasePainterDecorator(
interiorPainter, BaseEdgeEnum.BEFORE,
new WarningPainter(redWarningImage,
CellContentExtensions.WARNING_MARK_RED)),
BaseEdgeEnum.BEFORE,
new WarningPainter(blackWarningImage,
CellContentExtensions.WARNING_MARK_BLACK)),
BaseEdgeEnum.BEFORE,
new WarningPainter(leftWarningImage,
CellContentExtensions.WARNING_MARK_YELLOW)),
BaseEdgeEnum.AFTER,
new WarningPainter(rightWarningImage,
CellContentExtensions.WARNING_MARK_RED)),
new WarningPainter(yellowWarningImage,
CellContentExtensions.WARNING_MARK_YELLOW)),
TOP_PADDING, RIGHT_PADDING, BOTTOM_PADDING, LEFT_PADDING,
false));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,17 @@ public void createPainterInstances() {
final boolean calculateByTextLength = false;
final boolean calculateByTextHeight = true;

final Image leftWarningImage = createImage(resourceManager,
final Image yellowWarningImage = createImage(resourceManager,
SetImages.WARNING_YELLOW);
final Image rightWarningImage = createImage(resourceManager,
final Image redWarningImage = createImage(resourceManager,
SetImages.WARNING_RED);
final Image blackWarningImage = createImage(resourceManager,
SetImages.IC_WARNING_BLACK_18DP_1X);

this.defaultCellPainter = new PlanProTableCellPainter(
new PlanProRichTextCellPainter(wraptext, calculateByTextLength,
calculateByTextHeight),
leftWarningImage, rightWarningImage, blackWarningImage);
yellowWarningImage, redWarningImage, blackWarningImage);
this.filterRowCellPainter = new PaddingDecorator(
new FilterRowPainter(
new FilterIconPainter(GUIHelper.getImage("filter"))), //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory
import static extension com.google.common.base.Throwables.*
import static extension org.eclipse.set.model.tablemodel.extensions.TableRowExtensions.*
import static extension org.eclipse.set.ppmodel.extensions.utils.Debug.*
import org.eclipse.set.model.planpro.Basisobjekte.Ur_Objekt

/**
* Provides common functions for table transformations.
Expand Down Expand Up @@ -543,7 +544,7 @@ abstract class AbstractTableModelTransformator<T> implements TableModelTransform
) {
var guid = row.group.leadingObject?.identitaet?.wert
var leadingObject = getLeadingObjectIdentifier(row, guid)
var errorMsg = '''«e.class.simpleName»: "«e.message»" for leading object "«leadingObject»"'''
var errorMsg = e.createErrorMsg(row)

tableErrors.add(
new TableError(guid, leadingObject, "",
Expand All @@ -552,6 +553,24 @@ abstract class AbstractTableModelTransformator<T> implements TableModelTransform
logger.
error('''«e.class.simpleName» in column "«column.debugString»" for leading object "«leadingObject»" («guid»). «e.message»«System.lineSeparator»«e.stackTraceAsString»''')
}

def String createErrorMsg(
Exception e,
TableRow row
) {
var guid = row.group.leadingObject?.identitaet?.wert
var leadingObject = getLeadingObjectIdentifier(row, guid)
return e.createErrorMsg(leadingObject)
}

def String createErrorMsg(
Exception e,
String leadingObjectGuid
) {
var errorMsg = '''«e.class.simpleName»: "«e.message»" for leading object "«leadingObjectGuid»"'''
return '''«ERROR_PREFIX»«errorMsg»'''
}


/**
* Evaluates the given function with the given value for use in sorting.
Expand Down

0 comments on commit 327fd64

Please sign in to comment.