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

Remove scale property from Apollon #307

Merged
merged 18 commits into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion src/main/apollon-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class ApollonEditor {
view: ApollonView.Modelling,
mode: options.mode || ApollonMode.Exporting,
colorEnabled: options.colorEnabled || false,
scale: options.scale || 1.0,
zoomFactor: options.scale || 1.0,
readonly: options.readonly || false,
enablePopups: options.enablePopups === true || options.enablePopups === undefined,
enableCopyPasteToClipboard: options.copyPasteToClipboard === true,
Expand Down
28 changes: 13 additions & 15 deletions src/main/components/create-pane/create-pane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ type OwnProps = {};
type StateProps = {
type: UMLDiagramType;
colorEnabled: boolean;
scale: number;
};

type DispatchProps = {
Expand All @@ -42,43 +41,43 @@ type DispatchProps = {

type Props = OwnProps & StateProps & DispatchProps & I18nContext & CanvasContext;

const getInitialState = ({ type, canvas, translate, colorEnabled, scale }: Props) => {
const getInitialState = ({ type, canvas, translate, colorEnabled }: Props) => {
const previews: PreviewElement[] = [];
const utils: PreviewElement[] = [];

switch (type) {
case UMLDiagramType.ClassDiagram:
previews.push(...composeClassPreview(canvas, translate, scale));
previews.push(...composeClassPreview(canvas, translate));
break;
case UMLDiagramType.ObjectDiagram:
previews.push(...composeObjectPreview(canvas, translate, scale));
previews.push(...composeObjectPreview(canvas, translate));
break;
case UMLDiagramType.ActivityDiagram:
previews.push(...composeActivityPreview(canvas, translate, scale));
previews.push(...composeActivityPreview(canvas, translate));
break;
case UMLDiagramType.UseCaseDiagram:
previews.push(...composeUseCasePreview(canvas, translate, scale));
previews.push(...composeUseCasePreview(canvas, translate));
break;
case UMLDiagramType.CommunicationDiagram:
previews.push(...composeCommunicationPreview(canvas, translate, scale));
previews.push(...composeCommunicationPreview(canvas, translate));
break;
case UMLDiagramType.ComponentDiagram:
previews.push(...composeComponentPreview(canvas, translate, scale));
previews.push(...composeComponentPreview(canvas, translate));
break;
case UMLDiagramType.DeploymentDiagram:
previews.push(...composeDeploymentPreview(canvas, translate, scale));
previews.push(...composeDeploymentPreview(canvas, translate));
break;
case UMLDiagramType.PetriNet:
previews.push(...composePetriNetPreview(canvas, translate, scale));
previews.push(...composePetriNetPreview(canvas, translate));
break;
case UMLDiagramType.ReachabilityGraph:
previews.push(...composeReachabilityGraphPreview(canvas, translate, scale));
previews.push(...composeReachabilityGraphPreview(canvas, translate));
break;
case UMLDiagramType.SyntaxTree:
previews.push(...composeSyntaxTreePreview(canvas, translate, scale));
previews.push(...composeSyntaxTreePreview(canvas, translate));
break;
case UMLDiagramType.Flowchart:
previews.push(...composeFlowchartPreview(canvas, translate, scale));
previews.push(...composeFlowchartPreview(canvas, translate));
}
if (colorEnabled) {
utils.push(
Expand All @@ -100,7 +99,6 @@ const enhance = compose<ComponentClass<OwnProps>>(
(state) => ({
type: state.diagram.type,
colorEnabled: state.editor.colorEnabled,
scale: state.editor.scale,
}),
{
create: UMLElementRepository.create,
Expand Down Expand Up @@ -146,7 +144,7 @@ class CreatePaneComponent extends Component<Props, State> {
);

return (
<StoreProvider initialState={{ elements, editor: { features, scale: this.props.scale } }}>
<StoreProvider initialState={{ elements, editor: { features } }}>
{this.getElementArray(previews)}
{utils && utils.length > 0 ? (
<>
Expand Down
4 changes: 1 addition & 3 deletions src/main/components/sidebar/sidebar-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ type StateProps = {
mode: ApollonMode;
view: ApollonView;
selected: SelectableState;
scale: number;
};

type DispatchProps = {
Expand All @@ -34,7 +33,6 @@ const enhance = compose<ComponentClass<OwnProps>>(
mode: state.editor.mode,
view: state.editor.view,
selected: state.selected,
scale: state.editor.scale,
}),
{
changeView: EditorRepository.changeView,
Expand All @@ -47,7 +45,7 @@ class SidebarComponent extends Component<Props> {
if (this.props.readonly || this.props.mode === ApollonMode.Assessment) return null;

return (
<Container scale={this.props.scale} id="modeling-editor-sidebar" data-cy="modeling-editor-sidebar">
<Container id="modeling-editor-sidebar" data-cy="modeling-editor-sidebar">
{this.props.mode === ApollonMode.Exporting && (
<Switch value={this.props.view} onChange={this.props.changeView} color="primary">
<Switch.Item value={ApollonView.Modelling}>{this.props.translate('views.modelling')}</Switch.Item>
Expand Down
8 changes: 3 additions & 5 deletions src/main/components/sidebar/sidebar-styles.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import styled from 'styled-components';

export type ContainerProps = {
scale?: number;
};
export type ContainerProps = {};

export const Container = styled.aside.attrs<ContainerProps>({})<ContainerProps>`
flex: ${({ scale }: ContainerProps) => (scale ? `0 0 ${230 * scale}px` : '0 0 230px')};
padding: ${({ scale }: ContainerProps) => (scale ? `0 ${10 * scale}px` : '0 10px')};
flex: 0 0 230px;
padding: 0 10px;
height: 100%;
min-height: inherit;
max-height: inherit;
Expand Down
7 changes: 2 additions & 5 deletions src/main/components/theme/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ const apollonTheme = {
},
};

export const defaults = (scale: number = 1.0) => {
return {
...apollonTheme,
font: { ...apollonTheme.font, size: apollonTheme.font.size * scale },
};
export const defaults = () => {
return apollonTheme;
};
3 changes: 1 addition & 2 deletions src/main/components/theme/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import { defaults, Styles } from './styles';

const defaultProps = {
styles: {} as DeepPartial<Styles>,
scale: 1.0,
};

type Props = { children?: React.ReactChild } & typeof defaultProps;

export class Theme extends Component<Props> {
static defaultProps = defaultProps;

theme: Styles = update(defaults(this.props.scale), this.props.styles);
theme: Styles = update(defaults(), this.props.styles);

render() {
return <ThemeProvider theme={this.theme}>{this.props.children}</ThemeProvider>;
Expand Down
4 changes: 1 addition & 3 deletions src/main/components/uml-element/canvas-element.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ type StateProps = {
interactive: boolean;
interactable: boolean;
element: IUMLElement;
scale: number;
};

type DispatchProps = {};
Expand All @@ -40,7 +39,6 @@ const enhance = compose<ComponentClass<OwnProps>>(
interactive: state.interactive.includes(props.id),
interactable: state.editor.view === ApollonView.Exporting || state.editor.view === ApollonView.Highlight,
element: state.elements[props.id],
scale: state.editor.scale || 1.0,
}),
{},
),
Expand Down Expand Up @@ -87,7 +85,7 @@ class CanvasElementComponent extends Component<Props> {
fillOpacity={moving ? 0.7 : undefined}
fill={highlight}
>
<ElementComponent fillColor={highlight} scale={props.scale} element={UMLElementRepository.get(element)}>
<ElementComponent fillColor={highlight} element={UMLElementRepository.get(element)}>
{elements}
</ElementComponent>
{children}
Expand Down
5 changes: 1 addition & 4 deletions src/main/components/uml-element/canvas-relationship.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ type StateProps = {
disabled: boolean;
relationship: IUMLRelationship;
mode: ApollonMode;
scale: number;
readonly: boolean;
};

Expand Down Expand Up @@ -62,7 +61,6 @@ const enhance = compose<ComponentClass<OwnProps>>(
disabled: !!Object.keys(state.reconnecting).length || !!Object.keys(state.connecting).length,
relationship: state.elements[props.id] as IUMLRelationship,
mode: state.editor.mode as ApollonMode,
scale: state.editor.scale || 1.0,
readonly: state.editor.readonly || false,
}),
{
Expand All @@ -87,7 +85,6 @@ export class CanvasRelationshipComponent extends Component<Props, State> {
children,
theme,
mode,
scale,
readonly,
startwaypointslayout,
endwaypointslayout,
Expand Down Expand Up @@ -130,7 +127,7 @@ export class CanvasRelationshipComponent extends Component<Props, State> {
pointerEvents={disabled ? 'none' : 'stroke'}
>
<polyline points={points} stroke={highlight} fill="none" strokeWidth={STROKE} />
<ChildComponent scale={scale} element={UMLRelationshipRepository.get(relationship)} />
<ChildComponent element={UMLRelationshipRepository.get(relationship)} />
{children}
{midPoints.map((point, index) => {
return (
Expand Down
25 changes: 5 additions & 20 deletions src/main/components/uml-element/connectable/connectable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type StateProps = {
reconnecting: boolean;
element: IUMLElement;
type: UMLElementType | UMLRelationshipType;
scale: number;
};

type DispatchProps = {
Expand All @@ -45,7 +44,6 @@ const enhance = connect<StateProps, DispatchProps, UMLElementComponentProps, Mod
reconnecting: !!Object.keys(state.reconnecting).length,
element: state.elements[props.id],
type: state.elements[props.id].type as UMLElementType | UMLRelationshipType,
scale: state.editor.scale,
};
},
{
Expand All @@ -56,14 +54,14 @@ const enhance = connect<StateProps, DispatchProps, UMLElementComponentProps, Mod
);

const Handle = styled((props) => {
const { alternativePortVisualization, scale, ...otherProps } = props;
const { alternativePortVisualization, ...otherProps } = props;
// alternative port visualization size
const alternativePortHeight = 10 * scale;
const alternativePortWidth = 5 * scale;
const alternativePortCircleSize = 30 * scale;
const alternativePortHeight = 10;
const alternativePortWidth = 5;
const alternativePortCircleSize = 30;

// default port visualization size
const defaultPortSize = 20 * scale;
const defaultPortSize = 20;
if (alternativePortVisualization) {
return (
<svg {...otherProps}>
Expand Down Expand Up @@ -145,7 +143,6 @@ export const connectable = (
reconnect,
type,
element,
scale,
...props
} = this.props;

Expand All @@ -166,7 +163,6 @@ export const connectable = (
onPointerDown={this.onPointerDown}
onPointerUp={this.onPointerUp}
alternativePortVisualization={features.alternativePortVisualization}
scale={scale}
/>
)}
{this.props.type !== 'ActivityForkNodeHorizontal' && (
Expand All @@ -176,7 +172,6 @@ export const connectable = (
onPointerDown={this.onPointerDown}
onPointerUp={this.onPointerUp}
alternativePortVisualization={features.alternativePortVisualization}
scale={scale}
/>
)}
{this.props.type !== 'ActivityForkNode' && (
Expand All @@ -186,7 +181,6 @@ export const connectable = (
onPointerDown={this.onPointerDown}
onPointerUp={this.onPointerUp}
alternativePortVisualization={features.alternativePortVisualization}
scale={scale}
/>
)}

Expand All @@ -197,7 +191,6 @@ export const connectable = (
onPointerDown={this.onPointerDown}
onPointerUp={this.onPointerUp}
alternativePortVisualization={features.alternativePortVisualization}
scale={scale}
/>
)}

Expand All @@ -209,31 +202,27 @@ export const connectable = (
onPointerDown={this.onPointerDown}
onPointerUp={this.onPointerUp}
alternativePortVisualization={features.alternativePortVisualization}
scale={scale}
/>
<Handle
ports={ports}
direction={Direction.Upleft}
onPointerDown={this.onPointerDown}
onPointerUp={this.onPointerUp}
alternativePortVisualization={features.alternativePortVisualization}
scale={scale}
/>
<Handle
ports={ports}
direction={Direction.Downright}
onPointerDown={this.onPointerDown}
onPointerUp={this.onPointerUp}
alternativePortVisualization={features.alternativePortVisualization}
scale={scale}
/>
<Handle
ports={ports}
direction={Direction.Downleft}
onPointerDown={this.onPointerDown}
onPointerUp={this.onPointerUp}
alternativePortVisualization={features.alternativePortVisualization}
scale={scale}
/>
</>
)}
Expand All @@ -246,31 +235,27 @@ export const connectable = (
onPointerDown={this.onPointerDown}
onPointerUp={this.onPointerUp}
alternativePortVisualization={features.alternativePortVisualization}
scale={scale}
/>
<Handle
ports={ports}
direction={Direction.Topleft}
onPointerDown={this.onPointerDown}
onPointerUp={this.onPointerUp}
alternativePortVisualization={features.alternativePortVisualization}
scale={scale}
/>
<Handle
ports={ports}
direction={Direction.Bottomright}
onPointerDown={this.onPointerDown}
onPointerUp={this.onPointerUp}
alternativePortVisualization={features.alternativePortVisualization}
scale={scale}
/>
<Handle
ports={ports}
direction={Direction.Bottomleft}
onPointerDown={this.onPointerDown}
onPointerUp={this.onPointerUp}
alternativePortVisualization={features.alternativePortVisualization}
scale={scale}
/>
</>
)}
Expand Down
Loading
Loading