<commit_before>/**
 * This program and the accompanying materials
 * are made available under the terms of the License
 * which accompanies this distribution in the file LICENSE.txt
 */
package com.archimatetool.editor.diagram.figures.connections;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.RotatableDecoration;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.swt.SWT;

import com.archimatetool.editor.diagram.figures.geometry.PolarPoint;
import com.archimatetool.model.IDiagramModelArchimateConnection;


/**
 * Assignment Connection Figure class
 * 
 * @author <NAME>
 * @author <NAME>
 */
public class AssignmentConnectionFigure extends AbstractArchimateConnectionFigure {
	
    /**
     * @return Decoration to use on Target Node
     */
    public static class OvalDecoration extends Figure implements RotatableDecoration {

        private Point pRef;
        private int radius = 2;

        public OvalDecoration() {
            setSize(radius * 2 + 1, radius * 2 + 1);
        }

        public void setReferencePoint(Point ref) {
            pRef = ref.getCopy();
        }

        @Override
        public void setLocation(Point p) {
            PolarPoint pp = new PolarPoint(pRef, p.getCopy());
            pp.r -= radius;
            super.setLocation(pp.toAbsolutePoint(pRef).getTranslated(-radius, -radius));
        }

        @Override
        public void paintFigure(Graphics graphics) {
            graphics.setAntialias(SWT.ON);
            graphics.setBackgroundColor(ColorConstants.black);
            graphics.fillOval(bounds);
        }
    }

    /**
     * @return Decoration to use on Target Node
     */
    public static OvalDecoration createFigureTargetDecoration() {
        return new OvalDecoration();
    }
    
    /**
     * @return Decoration to use on Source Node<commit_msg>[Connections] Fix null pointer on OvalDecoration reference point<commit_after>/**
 * This program and the accompanying materials
 * are made available under the terms of the License
 * which accompanies this distribution in the file LICENSE.txt
 */
package com.archimatetool.editor.diagram.figures.connections;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.RotatableDecoration;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.swt.SWT;

import com.archimatetool.editor.diagram.figures.geometry.PolarPoint;
import com.archimatetool.model.IDiagramModelArchimateConnection;


/**
 * Assignment Connection Figure class
 * 
 * @author <NAME>
 * @author <NAME>
 */
public class AssignmentConnectionFigure extends AbstractArchimateConnectionFigure {
	
    /**
     * @return Decoration to use on Target Node
     */
    public static class OvalDecoration extends Figure implements RotatableDecoration {

        private Point pRef;
        private int radius = 2;

        public OvalDecoration() {
            setSize(radius * 2 + 1, radius * 2 + 1);
        }

        public void setReferencePoint(Point ref) {
            pRef = ref.getCopy();
        }

        @Override
        public void setLocation(Point p) {
            if(pRef != null) {
                PolarPoint pp = new PolarPoint(pRef, p.getCopy());
                pp.r -= radius;
                super.setLocation(pp.toAbsolutePoint(pRef).getTranslated(-radius, -radius));
            }
            else {
                super.setLocation(p);
            }
        }

        @Override
        public void paintFigure(Graphics graphics) {
            graphics.setAntialias(SWT.ON);
            graphics.setBackgroundColor(ColorConstants.black);
            graphics.fillOval(bounds);
        }
    }

    /**
     * @return Decoration to use on Target Node
     */
    public static OvalDecoration createFigureTargetDecoration() {
        return new OvalDecoration();
    }
    
    /**
     * @return Decoration to use on Source Node
{'fraction_non_alphanumeric': 0.08840327787434815, 'fraction_numerical': 0.004966476285075739, 'mean_word_length': 2.6223021582733814, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2283324', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1072, 'n_words': 278}