Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fbp 85 expanded collapsed process contd #286

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4c0682d
FBP-85. Continue working with expanded/collapsed subprocesses
valb3r Nov 14, 2021
faa751a
FBP-85. Restore status quo of subprocesses as it was before state ext…
valb3r Nov 14, 2021
cc92f13
FBP-85. Limit ExpandViewTransform propagation to elements of same lev…
valb3r Nov 15, 2021
5827db0
FBP-85. Fixed wrong ctor arguments order
valb3r Nov 15, 2021
86f4029
FBP-85. Fixed exception
valb3r Nov 15, 2021
06c0f95
FBP-85. Improve anchor selection
valb3r Nov 21, 2021
b4707dc
FBP-85. Improve attaching to collapsed subprocess of elements
valb3r Nov 21, 2021
ceb9e4b
FBP-85. Improve attaching to collapsed subprocess of elements
valb3r Nov 21, 2021
679cbfa
FBP-85. Handle element quirks when drawing new sequence
valb3r Nov 21, 2021
9e82d7e
FBP-85. Use DCEVM to runIde
valb3r Nov 21, 2021
704bce1
FBP-85. Correctly select anchors in case when quirks are active
valb3r Nov 21, 2021
aaa7bab
FBP-85. Fixed internal diagram elements affected by view transform
valb3r Nov 21, 2021
d46dc49
FBP-85. Register parent of parents for rectangular elements too
valb3r Nov 21, 2021
5cbae4b
FBP-85. Register parent of parents for rectangular elements too
valb3r Nov 21, 2021
daa765f
FBP-85. Fixed physical anchors rendering
valb3r Nov 21, 2021
4d45770
FBP-85. Fixed attachedTo ignored on physical waypoint
valb3r Nov 21, 2021
2f841de
FBP-85. Reorganize view transformation application mode
valb3r Nov 22, 2021
bb90690
FBP-85. Corrected indexOf usage
valb3r Nov 22, 2021
1c07f6c
FBP-85. Simplify model
valb3r Nov 22, 2021
5794e99
FBP-85. Fix not invoked inversion
valb3r Nov 23, 2021
f351d0f
FBP-85. Increase search area
valb3r Nov 24, 2021
5632c89
FBP-85. Example file and initial coordinate transform handling
valb3r Nov 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion activiti-intellij-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ intellij {
plugins = intellijPlatformPlugins
}

runIde {
jbrVersion = runIdeJbrVersion
}

publishPlugin {
token = intellijPublishToken
}
Expand Down Expand Up @@ -82,4 +86,4 @@ jacocoTestReport {
xml.enabled true
csv.enabled false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class DefaultBpmnProcessRenderer(private val project: Project, val icons: IconPr
}

private fun createRootProcessElem(state: () -> RenderState, elements: MutableList<BaseBpmnRenderElement>, elementsById: MutableMap<BpmnElementId, BaseDiagramRenderElement>): BaseBpmnRenderElement {
val processElem = PlaneRenderElement(state().currentState.processDiagramId(), state().currentState.processId, state, mutableListOf())
val processElem = PlaneRenderElement(state().currentState.processDiagramId(), state().currentState.processId, state)
elements += processElem
elementsById[state().currentState.processId] = processElem
return processElem
Expand Down Expand Up @@ -197,7 +197,7 @@ class DefaultBpmnProcessRenderer(private val project: Project, val icons: IconPr
elementsById.forEach { (id, renderElem) ->
val elem = state().currentState.elementByBpmnId[id]
elem?.parent?.let {elementsById[it]}?.let { if (it is BaseBpmnRenderElement) it else null }?.let { parent ->
parent.children.add(renderElem)
parent.addInnerElement(renderElem)
parent.let { renderElem.parents.add(it) }
}
}
Expand Down Expand Up @@ -243,8 +243,8 @@ class DefaultBpmnProcessRenderer(private val project: Project, val icons: IconPr
is BpmnSubProcess -> NoIconShape(id, bpmn.id, shape, state, Colors.PROCESS_COLOR, Colors.ELEMENT_BORDER_COLOR, Colors.SUBPROCESS_TEXT_COLOR, areaType = AreaType.SHAPE_THAT_NESTS)
is BpmnEventSubprocess -> NoIconShape(id, bpmn.id, shape, state, Colors.PROCESS_COLOR, Colors.ELEMENT_BORDER_COLOR, Colors.SUBPROCESS_TEXT_COLOR, areaType = AreaType.SHAPE_THAT_NESTS, borderStroke = DASHED_STROKE)
is BpmnTransactionalSubProcess -> NoIconDoubleBorderShape(id, bpmn.id, shape, state, areaType = AreaType.SHAPE_THAT_NESTS)
is BpmnCollapsedSubprocess -> ExpandableShapeNoIcon(id, bpmn.id, isCollapsed(bpmn.id, state), icons.plus, icons.minus, shape, state, areaType = AreaType.SHAPE_THAT_NESTS)
is BpmnTransactionCollapsedSubprocess -> ExpandableShapeNoIcon(id, bpmn.id, isCollapsed(bpmn.id, state), icons.plus, icons.minus, shape, state, areaType = AreaType.SHAPE_THAT_NESTS)
is BpmnCollapsedSubprocess -> ExpandableShapeNoIcon(id, bpmn.id, icons.plus, icons.minus, shape, state, areaType = AreaType.SHAPE_THAT_NESTS)
is BpmnTransactionCollapsedSubprocess -> ExpandableShapeNoIcon(id, bpmn.id, icons.plus, icons.minus, shape, state, areaType = AreaType.SHAPE_THAT_NESTS)
is BpmnCallActivity -> NoIconShape(id, bpmn.id, shape, state)
is BpmnAdHocSubProcess -> BottomMiddleIconShape(id, bpmn.id, icons.tilde, shape, state, areaType = AreaType.SHAPE_THAT_NESTS)
is BpmnExclusiveGateway -> IconShape(id, bpmn.id, icons.exclusiveGateway, shape, state)
Expand All @@ -269,10 +269,6 @@ class DefaultBpmnProcessRenderer(private val project: Project, val icons: IconPr
}
}

private fun isCollapsed(id: BpmnElementId, state: () -> RenderState): Boolean {
return !(state().currentState.elemUiOnlyPropertiesByStaticElementId[id]?.get(UiOnlyPropertyType.EXPANDED)?.value as Boolean? ?: false)
}

private fun drawSelectionRect(state: RenderContext) {
state.interactionContext.dragSelectionRect?.let {
val rect = it.toRect()
Expand Down Expand Up @@ -412,4 +408,4 @@ data class TreeState (
internal val version: Long,
) {
internal lateinit var domRoot: BaseBpmnRenderElement
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ import com.valb3r.bpmn.intellij.plugin.core.render.elements.RenderState
import com.valb3r.bpmn.intellij.plugin.core.state.CurrentStateProvider

data class RenderContext(
val project: Project,
val canvas: CanvasPainter,
val selectedIds: Set<DiagramElementId>,
val interactionContext: ElementInteractionContext,
val stateProvider: CurrentStateProvider,
var cachedDom: TreeState? = null
)
val project: Project,
val canvas: CanvasPainter,
val selectedIds: Set<DiagramElementId>,
val interactionContext: ElementInteractionContext,
val stateProvider: CurrentStateProvider,
var cachedDom: TreeState? = null
) {
// Just a FIXME for Kotlin debugger not to get to OutOfMemory
override fun toString(): String {
return ""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,20 @@ abstract class BaseDiagramRenderElement(
var isVisible: Boolean? = null

abstract val areaType: AreaType
open val children: MutableList<BaseDiagramRenderElement> = mutableListOf()
protected val innerElements: MutableList<BaseDiagramRenderElement> = mutableListOf()
open val children: List<BaseDiagramRenderElement> = innerElements

/**
* Parents in the order: direct parent, parent of direct parent...
* Typically 'direct parent' is sufficient and is only provided
*/
open val parents: MutableList<BaseBpmnRenderElement> = mutableListOf()

/**
* View transformation level for this element (will limit scoped view transformation to this level)
*/
open var viewTransformLevel: DiagramElementId? = null

open fun multipleElementsSelected(): Boolean {
return state().ctx.selectedIds.size > 1
}
Expand Down Expand Up @@ -121,6 +127,13 @@ abstract class BaseDiagramRenderElement(
return result
}

open fun addInnerElement(elem: BaseDiagramRenderElement) {
elem.viewTransformLevel = this.viewTransformLevel
innerElements.add(elem)
}

abstract fun currentRect(): Rectangle2D.Float

protected open fun rootAndEnumerateChildrenRecursively(root: BaseDiagramRenderElement) : List<BaseDiagramRenderElement> {
val result = mutableListOf<BaseDiagramRenderElement>()
result += root
Expand Down Expand Up @@ -219,8 +232,7 @@ abstract class BaseDiagramRenderElement(
abstract fun doResizeWithoutChildren(dw: Float, dh: Float)
abstract fun doResizeEndWithoutChildren(dw: Float, dh: Float): MutableList<Event>

protected abstract fun currentRect(): Rectangle2D.Float
protected abstract fun currentOnScreenRect(camera: Camera): Rectangle2D.Float
abstract fun currentOnScreenRect(camera: Camera): Rectangle2D.Float

protected abstract fun waypointAnchors(camera: Camera): MutableSet<Anchor>
protected abstract fun shapeAnchors(camera: Camera): MutableSet<Anchor>
Expand All @@ -246,17 +258,18 @@ abstract class BaseDiagramRenderElement(
val batch = findExpansionViewTransformationsToCompensate()

val trackingPoint = Point2D.Float(rect.x, rect.y)
val viewTransformedPoint = batch.transform(elementId, trackingPoint)
val transform = PointTransformationIntrospection(applyTransformationAt = viewTransformLevel)
val viewTransformedPoint = batch.transform(elementId, trackingPoint, transform)
val currentPoint = Point2D.Float(viewTransformedPoint.x + dx, viewTransformedPoint.y + dy)
val inverted = ViewTransformInverter().invert(elementId, currentPoint, trackingPoint, batch)
val inverted = ViewTransformInverter().invert(elementId, currentPoint, trackingPoint, batch, transform)

return Point2D.Float(inverted.x - rect.x, inverted.y - rect.y)
}

protected fun compensateExpansionViewOnLocation(targetElement: DiagramElementId, location: Point2D.Float, initialGuess: Point2D.Float): Point2D.Float {
protected fun compensateExpansionViewOnLocation(elementToCompensate: DiagramElementId, location: Point2D.Float, initialGuess: Point2D.Float, target: DiagramElementId?): Point2D.Float {
val batch = findExpansionViewTransformationsToCompensate()

val inverted = ViewTransformInverter().invert(targetElement, location, initialGuess, batch)
val inverted = ViewTransformInverter().invert(elementToCompensate, location, initialGuess, batch, PointTransformationIntrospection(target, applyTransformationAt = this.viewTransformLevel))

return Point2D.Float(inverted.x, inverted.y)
}
Expand All @@ -283,4 +296,4 @@ abstract class BaseDiagramRenderElement(
currentOnScreenRect(state().ctx.canvas.camera)
children.forEach {it.currentOnScreenRect(state().ctx.canvas.camera)}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import java.awt.geom.Rectangle2D

abstract class AnchorElement(
elementId: DiagramElementId,
private val attachedTo: DiagramElementId?,
protected val attachedTo: DiagramElementId?,
protected val currentLocation: Point2D.Float,
state: () -> RenderState
): BaseDiagramRenderElement(elementId, state) {
Expand All @@ -25,7 +25,7 @@ abstract class AnchorElement(
get() = currentLocation

val transformedLocation: Point2D.Float
get() = state().viewTransform(elementId).transform(elementId, currentLocation, PointTransformationIntrospection(attachedTo))
get() = state().viewTransform(elementId).transform(elementId, currentLocation, PointTransformationIntrospection(attachedTo, viewTransformLevel))

override fun drawActionsRight(x: Float, y: Float): Map<DiagramElementId, AreaWithZindex> {
// NOP
Expand Down Expand Up @@ -68,4 +68,4 @@ abstract class AnchorElement(
override fun getEventsToDeleteElement(): List<BpmnElementRemovedEvent> {
return listOf()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ abstract class CircleAnchorElement(
elementId: DiagramElementId,
attachedTo: DiagramElementId?,
currentLocation: Point2D.Float,
private val radius: Float,
protected val radius: Float,
private val bodyColor: Colors,
state: () -> RenderState
) : AnchorElement(elementId, attachedTo, currentLocation, state) {
Expand All @@ -39,7 +39,9 @@ abstract class CircleAnchorElement(
2.0f * radius,
2.0f * radius
),
AreaType.POINT
AreaType.POINT,
viewTransformLevel,
attachedTo = attachedTo
)
)
}
Expand Down Expand Up @@ -95,4 +97,4 @@ abstract class CircleAnchorElement(
protected open fun isRenderable(): Boolean {
return true
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class EdgeExtractionAnchor(
imageHeight
),
AreaType.POINT,
parent
viewTransformLevel,
attachedTo = parent
)
)
}
Expand Down Expand Up @@ -78,4 +79,4 @@ class EdgeExtractionAnchor(
override fun waypointAnchors(camera: Camera): MutableSet<Anchor> {
return mutableSetOf(Anchor(transformedLocation))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class ShapeResizeAnchorBottom(
icon.iconHeight.toFloat()
),
AreaType.SHAPE,
parent
viewTransformLevel,
attachedTo = parent
)
)
}
Expand Down Expand Up @@ -62,4 +63,4 @@ class ShapeResizeAnchorBottom(
override fun zIndex(): Int {
return ICON_Z_INDEX
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class ShapeResizeAnchorTop(
height
),
AreaType.SHAPE,
parent
viewTransformLevel,
attachedTo = parent
)
)
}
Expand Down Expand Up @@ -67,4 +68,4 @@ class ShapeResizeAnchorTop(
override fun zIndex(): Int {
return ICON_Z_INDEX
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ class VirtualWaypoint(
override fun waypointAnchors(camera: Camera): MutableSet<Anchor> {
return if (isActiveOrDragged()) return super.waypointAnchors(camera) else mutableSetOf()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class ButtonWithAnchor(
imageWidth,
imageHeight
),
AreaType.POINT
AreaType.POINT,
viewTransformLevel
)
)
}
Expand Down Expand Up @@ -73,4 +74,4 @@ class ButtonWithAnchor(
override fun waypointAnchors(camera: Camera): MutableSet<Anchor> {
return mutableSetOf(Anchor(transformedLocation))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import com.valb3r.bpmn.intellij.plugin.core.render.elements.RenderState
import com.valb3r.bpmn.intellij.plugin.core.render.elements.anchors.AnchorElement
import com.valb3r.bpmn.intellij.plugin.core.render.elements.anchors.PhysicalWaypoint
import com.valb3r.bpmn.intellij.plugin.core.render.elements.anchors.VirtualWaypoint
import com.valb3r.bpmn.intellij.plugin.core.render.elements.viewtransform.PointTransformationIntrospection
import com.valb3r.bpmn.intellij.plugin.core.render.elements.viewtransform.RectangleTransformationIntrospection
import java.awt.Color
import java.awt.geom.Area
import java.awt.geom.Point2D
Expand All @@ -32,7 +34,15 @@ abstract class BaseEdgeRenderElement(

private val anchors = computeAnchors()

override val children: MutableList<BaseDiagramRenderElement> = anchors as MutableList<BaseDiagramRenderElement>
override var viewTransformLevel: DiagramElementId? = null
get() = super.viewTransformLevel
set(value) {
super.viewTransformLevel = value
field = value
anchors.forEach { it.viewTransformLevel = value}
}

override val children: List<BaseDiagramRenderElement> = anchors as MutableList<BaseDiagramRenderElement> + innerElements

val edgeElem: EdgeWithIdentifiableWaypoints
get() = edge
Expand Down Expand Up @@ -90,17 +100,17 @@ abstract class BaseEdgeRenderElement(
}

override fun currentOnScreenRect(camera: Camera): Rectangle2D.Float {
val minX = edge.waypoint.minBy { it.x }?.x ?: 0.0f
val minY = edge.waypoint.minBy { it.y }?.y ?: 0.0f
val maxX = edge.waypoint.maxBy { it.x }?.x ?: 0.0f
val maxY = edge.waypoint.maxBy { it.y }?.y ?: 0.0f
val elems = anchors.filterIsInstance<PhysicalWaypoint>().map { it.transformedLocation }
val stX = elems.minBy { it.x }?.x ?: 0.0f
val stY = elems.minBy { it.y }?.y ?: 0.0f
val enX = elems.maxBy { it.x }?.x ?: 0.0f
val enY = elems.maxBy { it.y }?.y ?: 0.0f

// Edge itself can't be translated, so no viewTransform
return Rectangle2D.Float(
minX,
minY,
maxX - minX,
maxY - minY
stX,
stY,
enX - stX,
enY - stY
)
}

Expand Down Expand Up @@ -150,12 +160,14 @@ abstract class BaseEdgeRenderElement(
val numPhysicals = edge.waypoint.filter { it.physical }.size
var physicalPos = -1
return edge.waypoint.map {
if (it.physical) {
val result = if (it.physical) {
physicalPos++
PhysicalWaypoint(it.id, findAttachedToElement(physicalPos, numPhysicals), edge.id, edge.bpmnElement, edge, physicalPos, numPhysicals, Point2D.Float(it.x, it.y), state).let { it.parents.add(this); it }
} else {
VirtualWaypoint(it.id, edge.id, edge, Point2D.Float(it.x, it.y), state).let { it.parents.add(this); it }
}
result.viewTransformLevel = viewTransformLevel
return@map result
}.toMutableList()
}

Expand All @@ -172,4 +184,4 @@ abstract class BaseEdgeRenderElement(
else -> null
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import java.awt.geom.Rectangle2D
class PlaneRenderElement(
elementId: DiagramElementId,
bpmnElementId: BpmnElementId,
state: () -> RenderState,
override val children: MutableList<BaseDiagramRenderElement> = mutableListOf()
state: () -> RenderState
): BaseBpmnRenderElement(elementId, bpmnElementId, state) {

override val areaType: AreaType
Expand Down Expand Up @@ -70,6 +69,11 @@ class PlaneRenderElement(
override fun drawActionsRight(x: Float, y: Float): Map<DiagramElementId, AreaWithZindex> {
return mutableMapOf()
}

override fun addInnerElement(elem: BaseDiagramRenderElement) {
elem.viewTransformLevel = this.elementId
innerElements.add(elem)
}
}

private class InfiniteShape: Area() {
Expand Down Expand Up @@ -105,4 +109,4 @@ private class InfiniteShape: Area() {
override fun getBounds(): Rectangle {
return Rectangle()
}
}
}
Loading