Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
36 changes: 36 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: SonarCloud
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build and analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=refactor-metricas-larios-luna
6 changes: 5 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
<groupId>ImageJ</groupId>
<artifactId>ImageJ</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<sonar.organization>metricas-refactor-larios-luna</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
Expand All @@ -24,4 +28,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
2 changes: 2 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sonar.projectKey=refactor-metricas-larios-luna
sonar.organization=metricas-refactor-larios-luna
97 changes: 1 addition & 96 deletions src/ij/gui/OvalRoi.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,102 +147,7 @@ protected void moveHandle(int sx, int sy) {
}

}

if (constrain) {
if (activeHandle==1 || activeHandle==5) width=height;
else height=width;

if (x>=x2) {
width=1;
x=x2=xc;
}
if (y>=y2) {
height=1;
y=y2=yc;
}
switch(activeHandle){
case 0:
x=x2-width;
y=y2-height;
break;
case 1:
x=xc-width/2;
y=y2-height;
break;
case 2:
y=y2-height;
break;
case 3:
y=yc-height/2;
break;
case 5:
x=xc-width/2;
break;
case 6:
x=x2-width;
break;
case 7:
y=yc-height/2;
x=x2-width;
break;
}
if (center){
x=xc-width/2;
y=yc-height/2;
}
}

if (aspect && !constrain) {
if (activeHandle==1 || activeHandle==5) width=(int)Math.rint((double)height*asp);
else height=(int)Math.rint((double)width/asp);

switch (activeHandle) {
case 0:
x=x2-width;
y=y2-height;
break;
case 1:
x=xc-width/2;
y=y2-height;
break;
case 2:
y=y2-height;
break;
case 3:
y=yc-height/2;
break;
case 5:
x=xc-width/2;
break;
case 6:
x=x2-width;
break;
case 7:
y=yc-height/2;
x=x2-width;
break;
}
if (center) {
x=xc-width/2;
y=yc-height/2;
}
// Attempt to preserve aspect ratio when roi very small:
if (width<8) {
if (width<1) width = 1;
height=(int)Math.rint((double)width/asp_bk);
}
if (height<8) {
if (height<1) height =1;
width=(int)Math.rint((double)height*asp_bk);
}
}

updateClipRect();
imp.draw(clipX, clipY, clipWidth, clipHeight);
oldX=x; oldY=y;
oldWidth=width; oldHeight=height;
cachedMask = null;
bounds = null;
this.conditionMoveHandle(x2, xc, y2, yc, asp, true);
}

public void draw(Graphics g) {
Expand Down
206 changes: 107 additions & 99 deletions src/ij/gui/Roi.java
Original file line number Diff line number Diff line change
Expand Up @@ -923,104 +923,8 @@ private void growConstrained(int xNew, int yNew) {
oldWidth = width;
oldHeight = height;
}

protected void moveHandle(int sx, int sy) {
double asp;
if (clipboard!=null) return;
int ox = ic.offScreenX2(sx);
int oy = ic.offScreenY2(sy);
if (ox<0) ox=0; if (oy<0) oy=0;
if (ox>xMax) ox=xMax; if (oy>yMax) oy=yMax;
int x1=x, y1=y, x2=x1+width, y2=y+height, xc=x+width/2, yc=y+height/2;
if (width > 7 && height > 7) {
asp = (double)width/(double)height;
asp_bk = asp;
} else
asp = asp_bk;

switch (activeHandle) {
case 0:
x=ox; y=oy;
break;
case 1:
y=oy;
break;
case 2:
x2=ox; y=oy;
break;
case 3:
x2=ox;
break;
case 4:
x2=ox; y2=oy;
break;
case 5:
y2=oy;
break;
case 6:
x=ox; y2=oy;
break;
case 7:
x=ox;
break;
}
if (x<x2)
width=x2-x;
else
{width=1; x=x2;}
if (y<y2)
height = y2-y;
else
{height=1; y=y2;}

if (center) {
switch (activeHandle){
case 0:
width=(xc-x)*2;
height=(yc-y)*2;
break;
case 1:
height=(yc-y)*2;
break;
case 2:
width=(x2-xc)*2;
x=x2-width;
height=(yc-y)*2;
break;
case 3:
width=(x2-xc)*2;
x=x2-width;
break;
case 4:
width=(x2-xc)*2;
x=x2-width;
height=(y2-yc)*2;
y=y2-height;
break;
case 5:
height=(y2-yc)*2;
y=y2-height;
break;
case 6:
width=(xc-x)*2;
height=(y2-yc)*2;
y=y2-height;
break;
case 7:
width=(xc-x)*2;
break;
}
if (x>=x2) {
width=1;
x=x2=xc;
}
if (y>=y2) {
height=1;
y=y2=yc;
}
bounds = null;
}


protected void conditionMoveHandle(int x2, int xc, int y2, int yc, double asp, boolean isOval) {
if (constrain) {
if (activeHandle==1 || activeHandle==5)
width=height;
Expand Down Expand Up @@ -1118,7 +1022,111 @@ protected void moveHandle(int sx, int sy) {
oldX=x; oldY=y;
oldWidth=width; oldHeight=height;
bounds = null;
subPixel = false;
if(!isOval) {
subPixel = false;
}else {
cachedMask = null;
}

}

protected void moveHandle(int sx, int sy) {
double asp;
if (clipboard!=null) return;
int ox = ic.offScreenX2(sx);
int oy = ic.offScreenY2(sy);
if (ox<0) ox=0; if (oy<0) oy=0;
if (ox>xMax) ox=xMax; if (oy>yMax) oy=yMax;
int x1=x, y1=y, x2=x1+width, y2=y+height, xc=x+width/2, yc=y+height/2;
if (width > 7 && height > 7) {
asp = (double)width/(double)height;
asp_bk = asp;
} else
asp = asp_bk;

switch (activeHandle) {
case 0:
x=ox; y=oy;
break;
case 1:
y=oy;
break;
case 2:
x2=ox; y=oy;
break;
case 3:
x2=ox;
break;
case 4:
x2=ox; y2=oy;
break;
case 5:
y2=oy;
break;
case 6:
x=ox; y2=oy;
break;
case 7:
x=ox;
break;
}
if (x<x2)
width=x2-x;
else
{width=1; x=x2;}
if (y<y2)
height = y2-y;
else
{height=1; y=y2;}

if (center) {
switch (activeHandle){
case 0:
width=(xc-x)*2;
height=(yc-y)*2;
break;
case 1:
height=(yc-y)*2;
break;
case 2:
width=(x2-xc)*2;
x=x2-width;
height=(yc-y)*2;
break;
case 3:
width=(x2-xc)*2;
x=x2-width;
break;
case 4:
width=(x2-xc)*2;
x=x2-width;
height=(y2-yc)*2;
y=y2-height;
break;
case 5:
height=(y2-yc)*2;
y=y2-height;
break;
case 6:
width=(xc-x)*2;
height=(y2-yc)*2;
y=y2-height;
break;
case 7:
width=(xc-x)*2;
break;
}
if (x>=x2) {
width=1;
x=x2=xc;
}
if (y>=y2) {
height=1;
y=y2=yc;
}
bounds = null;
}
this.conditionMoveHandle(x2, xc, y2, yc, asp, false);
}

void move(int sx, int sy) {
Expand Down
Loading