The task: to prepare (draw in memory) an array of pictures ("characters of your font"), then to display them on the Canvas in different places, overlaying them on the background (which also changes dynamically). How to draw them in memory? How then to place them on the Canvas? As an example.

  • 2
    You do not understand how to handle arrays of objects? - Eugene Krivenja
  • There are no difficulties with simple arrays, but when I ran into arrays of elements of type Point, difficulties arose. Well, I would like to hear ideas about drawing. Is the correct approach or is it necessary to solve this problem somehow. - kaaa
  • Paint is not a picture. - Vladyslav Matviienko
  • Yes, I already knew what the nonsense wrote. Paint is one of their drawing options. It sets the graphic characteristics of drawing. We can assume that this is the brush with which the figures will be drawn. - kaaa
  • Metalargus, I have a business proposal for you. How to contact you? my mail is intent2joy@mail.ru - kaaa

1 answer 1

Read about ArrayList https://habrahabr.ru/post/128269/

HashMap https://habrahabr.ru/post/128017/

In fact, the problem has several solutions. You can store as the pictures themselves, then we will dance from a line like this:

 ArrayList<PaintObject> list = new ArrayList<PaintObject>(); 

Or this, if the pictures will be inserted according to certain rules:

 Map<Key,PaintObject> list = new Map<>(Key,PaintObjec); 

And links to pictures that are simply stored as separate files, then it will be an array of strings or objects based on its class, where the string and key will be stored. In any case, there is plenty of information on organizing an array, you just need to choose whether it will be a HashMap, Map, ArrayList or something else. It is important not only storage - it is also important what methods of processing this array will be. Do I need a search? Random insertion or by some rules? Adding new items to an array? The question is a bit vague, the right organization in one case will be wrong in the other. But as far as I understood, the Map is quite suitable.

ZY Game Balda what?))))

  • If the array consists of unique images - you can still Set to use. - FoeNicks
  • Drawings ("characters", "new font") are created in memory, and not loaded as files. They are created at the beginning of work (in memory as an array of pictures) and then simply used as "new fonts". - kaaa
  • TreeMap I think that will be the most. In either case, there will be a pair of key-letter-object-figure. You can read how to organize here. quizful.net/post/Java-TreeMap - FoeNicks