Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
yotta
/
pictogram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
60
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9a2b4543
authored
Dec 09, 2016
by
german
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Code changed to quit the legend_size attributes and "only_legend" code added
parent
c110ced3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
29 deletions
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/Picto.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/grammar/Vocabulary.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/PictogramActivity.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/Picto.java
View file @
9a2b4543
...
...
@@ -7,6 +7,9 @@ import android.graphics.BitmapFactory;
import
android.graphics.Canvas
;
import
android.graphics.Color
;
import
android.graphics.Matrix
;
import
android.graphics.Paint
;
import
android.graphics.PorterDuff
;
import
android.util.Log
;
import
android.util.TypedValue
;
...
...
@@ -53,13 +56,13 @@ public class Picto extends Img {
/**Modificacion German*/
public
static
String
LEGEND
=
"legend"
;
public
static
String
LEGEND_SIZE
=
"legend_size"
;
}
public
final
static
class
JSON_ATTTR_LEGEND_VALUES
{
static
String
NONE
=
"none"
;
static
String
NORMAL
=
"normal"
;
static
String
ONLY_LEGEND
=
"only_legend
"
;
static
String
FULL
=
"full
"
;
}
public
final
static
class
JSON_ATTTR_STATUS_VALUES
{
...
...
@@ -75,7 +78,7 @@ public class Picto extends Img {
private
JSONObject
attributes
;
private
String
translation
;
public
Picto
(
int
id
,
String
url
,
String
translation
,
int
cat
,
int
row
,
int
column
,
int
freeRow
,
int
freeColumn
,
boolean
legend
)
throws
JSONException
{
public
Picto
(
int
id
,
String
url
,
String
translation
,
int
cat
,
int
row
,
int
column
,
int
freeRow
,
int
freeColumn
)
throws
JSONException
{
this
(
id
,
url
,
translation
,
new
JSONObject
()
.
put
(
JSON_ATTTRS
.
CATEGORY
,
cat
)
.
put
(
JSON_ATTTRS
.
COLUMN
,
column
)
...
...
@@ -83,8 +86,7 @@ public class Picto extends Img {
.
put
(
JSON_ATTTRS
.
FREE_ROW
,
freeRow
)
.
put
(
JSON_ATTTRS
.
FREE_COLUMN
,
freeColumn
)
.
put
(
JSON_ATTTRS
.
STATUS
,
JSON_ATTTR_STATUS_VALUES
.
ENABLED
)
.
put
(
JSON_ATTTRS
.
LEGEND
,
legend
)
.
put
(
JSON_ATTTRS
.
LEGEND
,
JSON_ATTTR_LEGEND_VALUES
.
NORMAL
));
.
put
(
JSON_ATTTRS
.
LEGEND
,
JSON_ATTTR_LEGEND_VALUES
.
NONE
));
}
public
Picto
(
int
id
,
String
url
,
String
translation
,
String
attributes
)
throws
JSONException
{
this
(
id
,
url
,
translation
,
new
JSONObject
(
attributes
));
...
...
@@ -251,31 +253,18 @@ public class Picto extends Img {
/**
*
* @return the legend of a picto (
true | false
)
* @return the legend of a picto (
none | normal | full
)
*/
public
boolean
have
_legend
()
{
public
String
get
_legend
()
{
try
{
return
this
.
attributes
.
getBoolean
(
JSON_ATTTRS
.
LEGEND
);
return
this
.
attributes
.
getString
(
JSON_ATTTRS
.
LEGEND
);
}
catch
(
JSONException
e
)
{
return
false
;
// By default
return
"none"
;
// By default
}
}
/**
*
* @return the legend size of a picto (normal | only_legend)
*/
public
String
get_legend_size
()
{
try
{
return
this
.
attributes
.
getString
(
JSON_ATTTRS
.
LEGEND_SIZE
);
}
catch
(
JSONException
e
)
{
return
"normal"
;
// By default
}
}
/**
*
* @return the row of the picto
*/
public
int
get_row
()
{
...
...
@@ -459,10 +448,9 @@ public class Picto extends Img {
is
.
close
();
}
}
Paint
paint
=
new
Paint
(
Paint
.
ANTI_ALIAS_FLAG
);
if
(
have_legend
()){
if
(
get_legend_size
().
equals
(
JSON_ATTTR_LEGEND_VALUES
.
NORMAL
))
{
//if(!get_legend().equals(JSON_ATTTR_LEGEND_VALUES.NONE)){
String
texto
=
this
.
translation
.
toUpperCase
();
String
[]
words
=
texto
.
split
(
" "
);
...
...
@@ -503,6 +491,7 @@ public class Picto extends Img {
}
}
//if(get_legend().equals(JSON_ATTTR_LEGEND_VALUES.NORMAL)) {
android
.
graphics
.
Bitmap
.
Config
bitmapConfig
=
bitmap
.
getConfig
();
if
(
bitmapConfig
==
null
)
{
...
...
@@ -513,6 +502,15 @@ public class Picto extends Img {
Canvas
canvas
=
new
Canvas
(
bitmap
);
//Copiar el bitmap a uno nuevo y reescalar
int
width
=
bitmap
.
getWidth
();
//Ancho
int
height
=
bitmap
.
getHeight
();
//Alto
int
scaleWidth
=
50
/
width
;
int
scaleHeight
=
50
/
height
;
Bitmap
bm
=
Bitmap
.
createScaledBitmap
(
bitmap
,
50
,
50
,
false
);
canvas
.
drawColor
(
Color
.
TRANSPARENT
,
PorterDuff
.
Mode
.
CLEAR
);
canvas
.
drawBitmap
(
bm
,
25
,
0
,
null
);
TextView
textView
=
new
TextView
(
context
);
textView
.
layout
(
0
,
50
,
100
,
100
);
...
...
@@ -527,10 +525,38 @@ public class Picto extends Img {
textView
.
setDrawingCacheEnabled
(
true
);
canvas
.
drawBitmap
(
textView
.
getDrawingCache
(),
0
,
50
,
null
);
}
else
{
//
}else{
//Solo texto
/*android.graphics.Bitmap.Config bitmapConfig = bitmap.getConfig();
if (bitmapConfig == null) {
bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888;
}
bitmap = bitmap.copy(bitmapConfig, true);
Canvas canvas = new Canvas(bitmap);
paint.setColor(Color.WHITE);
canvas.drawRect(0,0,100,100,paint);
TextView textView = new TextView(context);
textView.layout(0, 0, 100, 100);
textView.setPadding(0, 0, 0, 0);
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, 15);
textView.setTextColor(Color.BLACK);
textView.setWidth(100);
textView.setGravity(Gravity.CENTER_HORIZONTAL);
textView.setMaxLines(2);
textView.setText(texto);
textView.setDrawingCacheEnabled(true);
canvas.drawBitmap(textView.getDrawingCache(), 0, 25, null);
}
}*/
return
bitmap
;
}
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/grammar/Vocabulary.java
View file @
9a2b4543
...
...
@@ -366,11 +366,11 @@ public class Vocabulary implements Iterable<Picto> {
/*
* It saves locally a new picto obtained from the PCB
*/
public
Picto
saveLocalPicto
(
String
url
,
String
exp
,
int
cat
,
int
coord_x
,
int
coord_y
,
int
free_category_coord_x
,
int
free_category_coord_y
,
boolean
legend
,
final
iLocalPicto
listener
)
{
public
Picto
saveLocalPicto
(
String
url
,
String
exp
,
int
cat
,
int
coord_x
,
int
coord_y
,
int
free_category_coord_x
,
int
free_category_coord_y
,
final
iLocalPicto
listener
)
{
int
id
=
PCBcontext
.
getDevice
().
getNextLocalPictoID
();
final
Picto
picto
[]=
new
Picto
[
1
];
try
{
picto
[
0
]
=
new
Picto
(
id
,
url
,
exp
,
cat
,
coord_x
,
coord_y
,
free_category_coord_x
,
free_category_coord_y
,
legend
);
picto
[
0
]
=
new
Picto
(
id
,
url
,
exp
,
cat
,
coord_x
,
coord_y
,
free_category_coord_x
,
free_category_coord_y
);
addPicto
(
picto
[
0
],
ImgDownloader
.
tsource
.
local
,
new
iImgDownloaderListener
()
{
@Override
public
void
loadComplete
()
{
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/PictogramActivity.java
View file @
9a2b4543
...
...
@@ -860,7 +860,6 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
col
,
freeRow
,
freeColumn
,
false
,
new
iLocalPicto
()
{
@Override
public
void
saved
(
Picto
localPicto
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment